Full Version: change option group status
UtterAccess Forums > Microsoft® Access > Access Forms
After learned how to use a cmd to change checkboxes in all row in a continuous form, I would like to do the same but for an option group.
uppose that the default value of the option group is 1 I tried this sql line:
Private Sub Cmd1_Click()
DoCmd.RunSQL "UPDATE MyTable SET Mytable.Option group = 2;"
End sub
but is not working rightly because is change only row by row after every click
thank you for any help
Doug Steele
I'm not sure DoCmd.Requery is correct: try explicitly requerying the form:
Private Sub Cmd1_Click()
  CurrentDb.Execute "UPDATE MyTable SET Mytable.Option group = 2;", dbFailOnError
End Sub

(Note that I'm using the database's Execute method to run the SQL. In my opinion, it's better than using RunSQL because it doesn't generate the annoying pop-up plus can generate a trappable error if something goes wrong)
Yes, you are right to avoid pop up warnings I use these statements
oCmd.SetWarnings False
and after
DoCmd.SetWarnings True
But the problem is the same... still change only row by row instead all rows with one click!
Doug Steele
Just to make certain: did you replace DoCmd.Requery with Me.Requery?
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.