UNION Query MS Jet Database Engine Cannot Find The Input Table Or Query.
Oct 28, 2005
Hello All,
I'm trying to run a UNION query that joins five queries through a MS WorkSpace into a DAO.recordset in VB. I'm pulling the data from a SQL Server Database through VB in Access. I'm attempting to open a recordset with a query passed to it as a string. The query is below. For some reason, I'm receiving a message: "MS Jet database engine cannot find the input table or query. Runtime Error 3078".
Here's what's puzzling. When I run a single query without any UNION statement, the code finds the table and runs fine without error, but anytime I join two or more queries with a UNION statement in the VB, it gives me the error.
I've executed the same UNION query in both Access Query Builder and SQL Server's Query Analyzer and they work fine in both environments. It's only when I call the query from a DAO.Recodset with VB that it causes this problem. The following is a sample of the UNION query joining two of the five queries. Does anyone have any idea what could be the problem? The following query executes in about 5 seconds so I don't think there's a "time-out" issue. I'm thinking that the UNION statement may be the culprit. Maybe there's another way to approach joining these separate queries? Any help would be most appreciated. Thanks.
SELECT SalespersonID, Sum([SlsPrice]-[RtnPrice]-[SlsDiscnt]+[RtnDiscnt]) AS fldPrice FROM MyTable WHERE (((Source)='d') AND ((DistrictID)='01') AND ((CategoryID) = 'HCPROD') AND ((BrandID)<>'CSS')) AND (((BrandID)<>'1356')) AND (((BrandID)<>'1400')) AND (((BrandID)<>'1551')) AND (((BrandID)<>'555')) AND (((BrandID)<>'66'))
AND (TransDate >= 07/01/2005) AND (TransDate <= 07/31/2005) GROUP BY SalespersonID
UNION
SELECT SalespersonID, Sum([SlsPrice]-[RtnPrice]-[SlsDiscnt]+[RtnDiscnt]) AS fldPrice FROM MyTable WHERE (((Source)='d') AND ((DistrictID)='01') AND ((ProductID) = '0029800')) AND (TransDate >= 07/01/2005) AND (TransDate <= 07/31/2005) GROUP BY SalespersonID
Set wrkJet = CreateWorkspace("", "pw", "", dbUseJet)
Set db = wrkJet.OpenDatabase("DW", _
dbDriverNoPrompt, True, _
"ODBC;DATABASE=DW;DSN=DW2")
'Set rs1 = db.OpenRecordset(strSQL)
I have an App that runs a few action queries using:
Code: CurrentDb.Execute "[My Query Name]"
At some point I get this Error: The Microsoft Access database engine cannot find the input table or query <name>. Make sure it exists and that its name is spelled correctly. (Error 3078).The query is there, I can run it from the DB objects window.Queries run using CurrentDb.Execute earlier in the code.
Based on information from a earlier thread.... I created a Union query that pulls information from multiple tables and fields.
SELECT AG_B_R1 as Num FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_B_R2 FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_B_R3 FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_B_R4 FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_m_R1 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_m_R2 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_m_R3 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_m_R4 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_e_R1 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_e_R2 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_e_R3 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll] UNION ALL SELECT AG_e_R4 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll];
And then I created another query to get the STDEV of the above query
SELECT StDev([Num]) AS StDev FROM Q_cals_ag_bme_STDEV_Union;
The result will be on a subform on my main page. How do I get my form to input the [roll] automatically and requery the subform, showing my result. Thanks
how to deal with errors specifically with error "The Microsoft Access database engine cannot find a record in table".Database which I'm creating have table Products, which contains information about products. Most important information in this table is if product is VATable or not. I decided to define product names in invoice table that database can recognize products and calculate VAT in invoices if product is VATable. Problem starts if you have new product. When I add new product in invoice it counts VAT but when i go to next record I receive message mentioned above. It doesn't allows me to go to next record or save record.
I was wondering is it possible to make it that access allows to fill invoice, informs about new products only when i have finished adding all products in invoice and than gives opportunity to add them to product list?
I am trying to get my VBA code to dump a query once the user pushes a button. I have the following code to call up the Excel app.
Code:
Option Compare Database Private Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long
[code]....
The qry_PP_Errors_Union is a Union query. In this query there is a date field. I would like to be able to to use that date field as a parameter. So I have written this VBA to prompt the user for a Begin Date and an End Date.
Now the part that I am missing is that I am not sure how to make the "strBegindate" and "strEnddate" the criteria for the union query.
The following is the SQL for my union query.
Code: SELECT LastName, FirstName, Title, TeamName, WorkOrderNumber, DateCompleted, WorkCode, UICError AS Error, "Update and Internal Correspondence" AS Category FROM qry_PP_UIC_Error UNION SELECT LastName, FirstName, Title, TeamName, WorkOrderNumber, DateCompleted, WorkCode, BIDError, "Bids" FROM qry_PP_Bid_Error
[Code] ....
Without the criteria, my code works for dumping everything out into Excel. However, dumping all the data results in a 7 mb Excel file that requires manual deletion of the information that is not pertinent.
I am having a problem running a make table query which is based on the same tables that I am using in a sub form.
Basically, the user selects certain records in the subform (which is in datasheet mode) using a check box, then once selected he hits a command button where there is some code that will run the make table query, which I use to filter other tables in a related reports.
However I keep getting this silly "database engine could not lock table" message relating to the sub form name. The subform is not linked to any records in the main form as the main form is unbound.
The solutions offered by putting DoEvents or Me.refresh/Me.requrey in the code do not work.
I have a live db running on a VPN network (FE/BE both centrally located on a main server , users 'view' their own personal front end through the VPN tunnel) ) and have recently provided a new updateto the FE. Until this time , most users were problem free but one persisted in getting the above error message. Now the new update is in place , they all get it, and this is when no one else is using the db and a single user logs in and tries to use the system. I guess it must be an internal fault ( ie my fault ) but then why does it work for some and not for others?. It also works no problem on my system at home. The user runs Access 2000 and the db was developed in 2003 ( default file format 2000) Any help most appreciated Thanks in advance.
I've added a list box to my form that displays a table. This table is completely independent and gains it's data from an Append query. There is also a Delete query, which clears the table for a new set of data, and an Alter query which resets an AutoNumber column in the table (so that new data sets always start numbered at 1).
Here's the problem: Since I've added the listbox and set the RowSource to the table, whenever I run the Append query I receive the error: "The database engine could not lock table 'tblLineSheet' because it is already in use by another person or process." I've made sure to close the table, but to no avail I still get this error. Without the List Box I don't encounter this error.
I'm having a problem with a UNION / UNION ALL query.It seems there is a application crash fault when running the query that MS are aware of and have issued a hot fix. Unfortunately it will take my IT dept some time to check and install the hot fix If they agree to do it at all.
Problem signature: Problem Event Name: APPCRASH Application Name: MSACCESS.EXE Application Version: 12.0.6606.1000
I have a table with a field I want to update with the value of a Union Query
The field I want to update is Yes/No format and I can update using 0 or -1 OK.
However, when I link in the union query (and check that I only have 1 update result which is either 0 or -1) I get an error message saying that Operation must use an updatable query.
I guess this is referring to the Union Query (although I am trying to update the table and not the query.
In short - I want to update a table based on the value of a union query.
Code: UPDATE tbl_StaMe_NGR_Subscription INNER JOIN qry_QDF_QRYDEF1 ON (tbl_StaMe_NGR_Subscription.EmailType = qry_QDF_QRYDEF1.Type) AND (tbl_StaMe_NGR_Subscription.AgentEmail = qry_QDF_QRYDEF1.Email)
Code: SET tbl_StaMe_NGR_Subscription.Subscribed = [Subscription];
I am using below Union Query to unpivot attached table. Basically this is a table with some clothes and their sizes (in yellow). Now my problem is that below query works well only when all sizes are in the same row but as per attachment I may have them potentially over three different rows.
I can determine which row is for which item based on size range column (in red) but I still do not know how to modify my query to look at different rows depending on value of size range column, especially that as you can see there are multiple values pointing out to the same size range i.e. 0-6 and 1-4 point out to Size Range 1.
Unfortunately I cannot change the layout of the table to have all sizes in one row
Code: Select Field1, Field2, "0" as Size,Field3 as Qty from orderform where Field3 > 0; Union All Select Field1, Field2, "1" as Size, Field4 as Qty from orderform where Field4 > 0; Union All Select Field1, Field2, "2" as Size, Field5 as Qty from orderform where Field5 > 0; Union All Select Field1, Field2, "3" as Size, Field6 as Qty from orderform where Field6 > 0; Union All Select Field1, Field2, "4" as Size, Field7 as Qty from orderform where Field7 > 0; Union All Select Field1, Field2, "5" as Size, Field8 as Qty from orderform where Field8 > 0; Union All Select Field1, Field2, "6" as Size, Field9 as Qty from orderform where Field9 > 0;
I have a DB with multiple import processes to take in information and populate various tables. This has been in place for some time and works with no issue.
The import process involves the creation of a local staging table, to which I import the received data, normalise it according to my own table structure, remove any duplication (i.e. same data imported repeatedly) and append the cleansed data to the main tables.
I've just added a validation step to check for data integrity. In other words, for duplicate data, rather than simply purge it as I was doing previously, I now check to see if the data has changed in any way and prompt the user if necessary (with the option to either ignore the change or update the existing record)
However, since I added this extra step, I am getting the following error message during my import process :
Error 3211 : The database engine could not lock table 'tblStaging' because it is already in use by another person or process
It only appears a) when a data change is detected and b) when the option to update is chosen, and seems to occur after the update has taken place (i.e. I can see the records suitably updated)
But I can't replicate the error while debugging so it seems to be a run-time issue. It's definitely not another user as the staging table is deliberately local (specific to that user's front-end)
I suspect I can probably solve the problem by adding some kind of DoEvents call or brief pause somewhere but the problem is, I don't know where the problem is occuring, so I don't know where to add the line? Or if that would even solve the problem at all?
Is there an easy function I can call to check if the staging table is locked? Which I could then use to debug and identify exactly where the lock is causing a problem? Or even apply the DoEvents to release the lock? (It must eventually get released as if I step through the code, I don't get the error?)
All I'm trying to do is a make table (table name to overwrite: "TBL_5_7_RFCs") query via VBA so I can loop through a set of VARs in a table. Here is my code:
Code:
Public Function test_sql() Dim Conn As ADODB.Connection Dim RS As New ADODB.Recordset Dim MySQL As String Set Conn = CurrentProject.Connection RS.ActiveConnection = Conn
[code]...
I'll add the loop and array once I get this working but I'm stuck.
I have 5 tables in access 2010, 4 of them have data in them and I need to populate the 5th table with all data from the 4 tables. I know you have to create a Union query, but i dont know the sql statement
Table 1 - data table 2 - data table 3 - data table 4 - data table 5 - combine data from table 1, table 2, table 3, table
I have a form that contains a subform. The subform is a datasheet which calls the results of a query of 4 tables (tbl_companies, tbl_deals, tbl_products, tbl_vl).
In the main form there is a button which opens a report with a historical record of dates of value changes of each product up to a chosen date. This chosen date is determined by inputting a date into a text box.
This report also sources (tbl_companies, tbl_deals, tbl_products, tbl_vl).
When I try to open the report, I get the run-time error "3211".
'The database engine could not lock the table "Tbl_companies" because its already in use by another person or process.'
I'm guessing that because the query for the subform is already calling the table, the query for the report can't call the table at the same time?
I'm looking for help with this error message: "Microsoft Jet database engine can't find the input table..." And the reason it can't find it seems to be that it's looking for an DBF file (which was a format I once had the data in, a long time ago) rather than the mdb file which I have been using forever. Any ideas?
I have a form that has a button that calls the following code:
Sub ClosePO_Click() Dim db As DAO.Database Dim mvalue As String, strSql as string Set db = CurrentDb mvalue = Me.Combo73 'combo box on OpenPO Form strSql = "UPDATE Print SET OpenPO = NO where [GPO Invoice Number] = '" & mvalue & "'" Debug.Print strSql db.Execute dbFailOnError db.Close Set db = Nothing End Sub
When I run (or step through the code, I get the Run-Time Error 3078 ... database cannot find the input table.However, when I copy the debug.print output in the immmediate window and paste into the query builder, the query runs. Here is an example of the debug.print output:
UPDATE [Print] set OpenPO = NO where [GPO Invoice Number] = '40333' where OpenPO is a yes/no field and [GPO Invoice Number] is a string
I wan to build a form with a blank text box (txtbx1) where users can enter a part description, this will search records in Table1>part and return a list of parts that match the textbox input.
Here's what I've done -
txtbx1 - property sheet - control source - part event - on enter - ...
I've built an expression -
[Table1]![part] = [txtbx1]
hoping that this would match records 1n Table1 to txtbx1
I'm trying my first query on the fly and am getting the above message when I try and build the query.
Ive posted the SQL below, can anyone tell me where I'm going wrong?
Private Sub Command24_Click() Dim dbsCurrent As Database Dim qdf As QueryDef Dim strSQL As String Set dbsCurrent = CurrentDb Set qdf = dbsCurrent.QueryDefs("qrycurrentinvs")
Dim VendId As String
VendId = "Like '" & Me.Text0.Value & " *' "
qdf.SQL = "SELECT dbo_pmt_rqst.[vendor_id], dbo_pmt_rqst.[vendor_loc_code], dbo_pmt_rqst.[pmt_rqst_nbr], dbo_pmt_rqst.[pmt_rqst_date], dbo_pmt_rqst.[payable_entity_id], dbo_pmt_rqst.[ctrl_grp_id], dbo_pmt_rqst.[ctrl_grp_date], Sum(dbo_pmt_rqst_tax.[tax_basis_amt]) AS Net, Sum(dbo_pmt_rqst_tax.[tax_amt]) AS VAT, Sum([tax_basis_amt]+[tax_amt]) AS Gross, dbo_pmt_rqst.[pmt_ref_nbr], dbo_pmt_rqst.[pmt_ref_date] INTO tblinvoices" & _ "FROM dbo_pmt_rqst INNER JOIN dbo_pmt_rqst_tax ON (dbo_pmt_rqst.pmt_rqst_date = dbo_pmt_rqst_tax.pmt_rqst_date) AND (dbo_pmt_rqst.pmt_rqst_nbr = dbo_pmt_rqst_tax.pmt_rqst_nbr) AND (dbo_pmt_rqst.vendor_loc_code = dbo_pmt_rqst_tax.vendor_loc_code) AND (dbo_pmt_rqst.vendor_id = dbo_pmt_rqst_tax.vendor_id)" & _ "WHERE dbo_pmt_rqst.vendor_id" & VendId & _ "GROUP BY dbo_pmt_rqst.vendor_id, dbo_pmt_rqst.vendor_loc_code, dbo_pmt_rqst.pmt_rqst_nbr, dbo_pmt_rqst.pmt_rqst_date, dbo_pmt_rqst.payable_entity_id, dbo_pmt_rqst.ctrl_grp_id, dbo_pmt_rqst.ctrl_grp_date, dbo_pmt_rqst.pmt_ref_nbr, dbo_pmt_rqst.pmt_ref_date, dbo_pmt_rqst.pmt_rqst_date, dbo_pmt_rqst_tax.tax_basis_amt, dbo_pmt_rqst.pmt_ref_date;"
I would like to create a query where I can search my selected fields on a particular field. However I do not want to do this in the standard way. I would like the query to appear in a 'search engine' type format (like a form but with a search). Is this possible????
I am building a mortgage/amortization database and I need to look up the "points paid" from another table and also the "adjustment to margin" based on the points paid and the index, "MTA" or "COFI". I have no idea how or where to write this lookup. Any suggestions?
I've inherited a rather large Access DB with many tables,forms, reports, and queries. I need to duplicate a process, but I'm having trouble finding the update qry that creates new records in a table.
I could write my own, but I am trying to create an exact duplicate so I'd really like to see the code that creates the new records for a specific table.