Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL update

Status
Not open for further replies.

tommeekers

Programmer
Sep 10, 2003
77
0
0
BE
I have a very weird problem with a very simple SQL query.

My main form has one subform and one button on it. In the subform I have a table in datasheet view. This table contains a few text fields and a Yes/No field called selected. The user can update this field directly on the datasheet by clicking the checkbox (marking the record as selected).
The button on my main form is used for selecting all records at once. I tried to do this with a simple SQL query.
Code:
DoCmd.RunSQL "UPDATE [i]MyTable[/i] SET [i]selected[/i] = True"
This returns an error Syntax error in UPDATE command, but to my best knowledge there is not syntax error in this line. Any idea what could prevent the update from working ?
 
Selected is a bad name for a field. Maybe "boolSelected" would be better. "Selected" is a property in VBA of a control, I think at a minimum you need [selected].
 
You might also try
Code:
DoCmd.RunSQL "UPDATE MyTable SET [selected] = " & True
or
Code:
DoCmd.RunSQL "UPDATE MyTable SET [selected] = -1"
 
I changed the name of the field to recordselect. I tried all possible combinations listed here, but still the same error keeps popping up. Any other ideas ?
Code:
DoCmd.RunSQL "UPDATE MyTable SET recordselect = True"
Code:
DoCmd.RunSQL "UPDATE [i]MyTable[/i] SET recordselect = -1"
Code:
DoCmd.RunSQL "UPDATE [i]MyTable[/i] SET [recordselect] = True"
Code:
DoCmd.RunSQL "UPDATE [i]MyTable[/i] SET [recordselect] = -1"
Code:
DoCmd.RunSQL "UPDATE [i]MyTable[/i] SET [recordselect] = " & True
 
Have you tried this...

Code:
DoCmd.RunSQL "UPDATE MyTable SET selected = True;"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top