Can't run SQL statements in VB code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to update a field in a certain table based on a certain yes/no
selection of a certain form. How is the best way to do this? I am currently
trying to run a VB script with a RunSQL statement based on an "Update" event
of the form. Am I looking at the right procedure for doing this? If so, I
don't seem to be configuring the RunSQL statement correctly.

Thanks in advance for any help.
Marty
 
try something along the lines of

If Me!CertainYesNo = True Then
CurrentDb.Execute "UPDATE MyTable SET FieldA = " _
& "'some value'", dbFailOnError
End If

if you use the form's BeforeUpdate event, make sure the code doesn't run if
the event is cancelled. you might want to use the AfterUpdate event,
instead.

hth
 
Back
Top