how can I correctly build the UPDATE action query?

M

Morris

I've got this:

strSQL = "UPDATE FilesToBuild SET FilesToBuild.GreenLight = True WHERE
"
strSQL = strSQL & "NameOfFile like '" & ID & "%' AND FilesToBuild.ToRun
= True"

In other words - I need to update those records that START with ID (eg
"41 bla bla bla" but not "123 bla bla week 41 bla bla") and have the
ToRun flag set to true.

VBCode screams an error on the "%" should I use asterisk?

[...] like " & chr(34) * ID % chr(34) & "AND [...] ?

cheers
 
D

Douglas J. Steele

VBA is complaining because you haven't got the % inside of quotes:

[...] like " & chr(34) & ID & "%" & chr(34) & " AND [...]

Are you using ADO to run the Update query? If you're using DAO, the wildcard
character is *, not %

The first example of VBA you've got, though, should be working (other than
the possible % vs. * issue), provided you have a space after WHERE before
the closing quote.
 

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