Minggu, 22 Januari 2017

RE: [MS_AccessPros] Run Time Error 3061

 

Hi David

 

It means that some text in your SQL string is not identified as a valid field name from your source tables, and so it is assumed to be a parameter.  Here is an easy way to find what it is:

1.       Set a breakpoint on the db.Execute line and run the code

2.       When it stops at the breakpoint, type ?strSQL in the immediate window to display the SQL string

3.       Select the SQL string in the immediate window and copy it (ctrl-C)

4.       Create a new query design and close the "Show Table" window, then switch to SQL view

5.       Paste your SQL string into the SQL window, replacing the "SELECT;" stub that is there

6.       Run the query – it will prompt you to provide a value for the missing "parameter", the name of which will be the offending item in the string.

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Monday, 23 January 2017 12:30
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Run Time Error 3061

 

 

I am trying to utilize some code that John provided me previously to create some records into a transaction table from a pair of related template tables.  HIs code works fine; mine doesn't (go figure, right?)

 

I put some debug.print statements into the code and the module works fine until it reaches the db.Execute strSQL statement, at which time it throws the error message "UNEXPECTED ERROR:3061; TOO FEW PARAMETERS, EXPECTED 1.  I can only guess it has something to do with My SQL statement but I cannot figure out what it is.  It is (at least to me) exactly as John's code which works.  I have just exchanged table names and field names.  BTW, all field names are ID fields and are long integers.

 

strSQL = "INSERT INTO tblInventoryDetails (InventoryHeaderID, StorageTankID, ProductID) " & _
            "SELECT " & Me.InventoryHeaderID & ", StorageTankID, ProductID " & _
            "FROM tblInventoryHeaderTemplates " & _
            "INNER JOIN tblInventoryDetailTemplates " & _
            "ON tblInventoryHeaderTemplates.InventoryHeaderTemplateID = tblInventoryDetailTemplates.InventoryHeaderTemplateID " & _
            "WHERE tblInventoryHeaderTemplates.InventoryHeaderTemplateID = " & Me.InventoryHeaderTemplateID & ";"

 


    db.Execute strSQL, dbFailOnError

 

__._,_.___

Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar