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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update field using a checkbox action

Status
Not open for further replies.

MontgomeryPete

Instructor
Apr 3, 2004
57
0
0
US
Hello:

I am trying to update a field based on the action taken on a checkbox as follows:

Code:
Private Sub Dispatched_AfterUpdate()
Dim strSQL As String
Set strSQL = "UPDATE Ride SET TimeDispatched = Now()"
DoCmd.RunSQL strSQL

End Sub

The error message returned is Object required (Error 424)and the Set strSQL is highlighted.

I can't seem to get around the debug statement.

Any thoughts?

Pete

 
I'd go with something like this. I assume the "TimeDispatched" is a bound control
Code:
Private Sub Dispatched_AfterUpdate()
    If Me.Dispatched.Value = -1 Then
        Me.TimeDispatched = Now
    Else
        Me.TimeDispatched = ""
    End If
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
How are ya MontgomeryPete . . .

[blue]strSQL[/blue] is a string, not an object! You Set objects! So you simply need:
Code:
[blue]   strSQL = "UPDATE Ride SET TimeDispatched = Now()"[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thnaks to both ZmrAbdulla and TheAceMan1 for different but good answers to the questions. Thanks much for the fast response.
Pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top