Select a field from a Query with VB Code

Xenix

Registered User.
Local time
Today, 00:24
Joined
Oct 8, 2001
Messages
124
Using the DoCmd.OpenQuery command
how can I now select each record in turn and set the value of [NewCustomer] to True?

Kind regards

Mike
 
Mike,

To run an "update" query, you want to use DoCmd.RunSQL(strYourSQL) instead of OpenQuery.

First you build an update statement in valid SQL and assign it to "strYourSQL" which will be a string variable.

Then you invoke RunSQL to perform the update.

RichM
 
Thank you Rich,

So I added:

DoCmd.RunSQL "UPDATE CustomerExport" & _
"SET CustomerExport.NewCustomer = TRUE" & _
"WHERE CustomerExport.NewCustomer = FALSE;"

but I now get a syntax error in UPDATE statement Run time error 3144 :(

what have I done wrong?


Regards

Mike
 
Mike,

<<
DoCmd.RunSQL "UPDATE CustomerExport" & _
"SET CustomerExport.NewCustomer = TRUE" & _
"WHERE CustomerExport.NewCustomer = FALSE;"
>>

You need spaces between the various parts of the string.

That might help.

RichM
 

Users who are viewing this thread

Back
Top Bottom