If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Update Query: Enter Parameter Value
I'm trying to set a field to a value that is stored in a variable using an
update query in VBA (Access 2003). The query prompts the user to enter parameter value, and the value of the variable displays in the pop up above the input text box of the pop up. The SQL is: DoCmd.RunSQL "UPDATE temptbl_ImportedPlateOrders SET temptbl_ImportedPlateOrders.GenSetName =" & strGenSetName strGenSetName is the varialbe and displays the correct value in when I mouse over it: strGenSetName = "G9999V00.txt" Can someone identify what I'm doing wrong. Thanks in advance. You always provide great advice. |
#2
|
|||
|
|||
Update Query: Enter Parameter Value
CC wrote:
I'm trying to set a field to a value that is stored in a variable using an update query in VBA (Access 2003). The query prompts the user to enter parameter value, and the value of the variable displays in the pop up above the input text box of the pop up. The SQL is: DoCmd.RunSQL "UPDATE temptbl_ImportedPlateOrders SET temptbl_ImportedPlateOrders.GenSetName =" & strGenSetName strGenSetName is the varialbe and displays the correct value in when I mouse over it: strGenSetName = "G9999V00.txt" Can someone identify what I'm doing wrong. Thanks in advance. You always provide great advice. It appears the GenSetName is a text field, then you need text delimiters on the value ....GenSetName ='" & strGenSetName & "'" or ....GenSetName =""" & strGenSetName & """" -- Roy-Vidar |
#3
|
|||
|
|||
Update Query: Enter Parameter Value
CC wrote:
I'm trying to set a field to a value that is stored in a variable using an update query in VBA (Access 2003). The query prompts the user to enter parameter value, and the value of the variable displays in the pop up above the input text box of the pop up. The SQL is: DoCmd.RunSQL "UPDATE temptbl_ImportedPlateOrders SET temptbl_ImportedPlateOrders.GenSetName =" & strGenSetName strGenSetName is the varialbe and displays the correct value in when I mouse over it: strGenSetName = "G9999V00.txt" Can someone identify what I'm doing wrong. Thanks in advance. You always provide great advice. As an alternative to Roy's advice, you can avoid the delimiter issue entirely by using a querydef's parameters collection. Like this: dim qdf as querydef 'you might have to add a reference to DAO dim sSQL as string sSQL="UPDATE temptbl_ImportedPlateOrders SET " & _ "GenSetName =[p1]" set qdf=currentdb.createquerydef("",sSQL) qdf(0) = strGenSetName qdf.execute -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" |
Thread Tools | |
Display Modes | |
|
|