Easy one

MvP14

Registered User.
Local time
Today, 22:18
Joined
Apr 15, 2003
Messages
66
I can't find what is wrong in the following code:

DoCmd.RunSQL "UPDATE Table1" & _
"SET Table1.Checkbox1 = False" & _
"WHERE Table1.Checkbox1 = True;"

Can anyone help me out? Thank you.
 
Strange title..easy one! How do you know it's easy? :cool:

At first glance I'd say it's because you are lacking spaces in your SQL statement.

you are building an SQL statement that read like this:

"UPDATE Table1SET Table1.Checkbox1 = FalseWHERE Table1.Checkbox1 = True;"

As you can see, the areas in bold are being concatenated in the statement you have built.

Try this:

DoCmd.RunSQL "UPDATE Table1 " & _
"SET Table1.Checkbox1 = False " & _
"WHERE Table1.Checkbox1 = True;"
 
That did it for me. Thank you.

When I run the command, I get a message box now. Is there a way I can avoid that?
 
Change your code to this:

Code:
With DoCmd
    .SetWarnings False
    .RunSQL "UPDATE Table1 " & _ 
        "SET Table1.Checkbox1 = False " & _ 
        "WHERE Table1.Checkbox1 = True;"
    .SetWarnings True
End With
 

Users who are viewing this thread

Back
Top Bottom