probably a dumb error

border20

Registered User.
Local time
Today, 13:58
Joined
Jan 8, 2003
Messages
92
In a field I want to change all the value that are o to 1.

I have the folowing code wich gives me an error...
can anyone tell me why ?

code

Dim sqlStr1 As String
sqlStr1 = "UPDATE tablename SET [field name] = 1 WHERE [field name] = 0;"
DoCmd.RunSQL sqlStr1

thx
 
What is the text of the error message you receive?
 
I get a syntaxe error
 
Why not just say...

DoCmd.RunSQL "UPDATE tablename SET [field name] = 1 WHERE [field name] = 0;"

Other than that, the form wher eyou are using this code, is it bound to this table? If so, you won't be able to run updates on it while it is in use.

Vassago
 
nope

i tried running the suggested line but I get the same syntax error... and the form is not liked to the table... i double checked by running the command in a new form...
 
Try pasting the SQL string into a query to see if it works there. You'll be able to tell if the query is the problem or the VBA.
 

Users who are viewing this thread

Back
Top Bottom