Update Form fields when check box clicked RRS feed

  • Question

  • I have a form for checking in and checking out items.  It uses a "Checked In" check box that is a Yes\No field.  I wish to update either the checked in date/time field or the checked out date/time field depending on the state of the Checked In check box when it is clicked.

    Here is the code which doesn't error but does nothing.  I have also tried the same code in the AfterUpdate event with the same result.  I think I need something more in the passing of the Now() function to the desired field but am not sure what.

    Private Sub CheckedIn_Click()

    If CheckedIn = 0 Then

    CheckedOutTime = Now()

    ElseIf CheckedIn = -1 Then

    CheckedInTime = Now()


    End If

    End Sub

    Wednesday, November 1, 2017 8:04 PM

All replies

  • Hi,

    Is your database stored in a Trusted Location or otherwise content is enabled? Meaning, do you know if VBA code is actually executing? If so, then are you sure the event is being triggered? If so, have you tried stepping through it to see what values are being passed around? For example, when you click on the checkbox, can you verify the value in CheckedIn is either 0 or 1 and it matches if the box is checked or not?

    Just a thought...

    Wednesday, November 1, 2017 9:04 PM
  • Hi TraceMachine,

    Could you share us your simple file?

    I made a test with below code, it works correctly.

    Private Sub CheckedIn_AfterUpdate()
    If CheckedIn = True Then
        DTime = Now()
        MsgBox "Checked"
        DTime = Now() - 1
        MsgBox "Not Checked"
    End If
    End Sub

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, November 16, 2017 8:21 AM