Update Query: Enter Parameter Value

C

CC

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.
 
R

RoyVidar

CC said:
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 & """"
 
B

Bob Barrows

CC said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top