Form checkbox updates date in another table (1 Viewer)

hllary

Registered User.
Local time
Today, 01:00
Joined
Sep 23, 2019
Messages
80
I'm trying to make a form checkbox update a the date in another table.

Code:
Private Sub Delivered_AfterUpdate()
    If Delivered = -1 Then
    [tool implentation].[date] = Now()
End Sub

This is code I have but it does not work. What should I do?

Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:00
Joined
Oct 29, 2018
Messages
21,455
Hi. If you're saying the form you're using is not bound to the table you're trying to update, then the question would be why is that? What is updating this date all about?
 

hllary

Registered User.
Local time
Today, 01:00
Joined
Sep 23, 2019
Messages
80
I'm new access and I don't know what you mean by bound. The date and checkbox are from the same table but I don't want to have the date field on the form.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:00
Joined
May 7, 2009
Messages
19,230
Code:
Private Sub Delivered_AfterUpdate()
    If Delivered = -1 Then  _
    Currentdb.Execute "Update [tool implentation] Set [date] = Now();"
End Sub

sorry, if both fields are in the same table, try this:
bring your form in design view.
on its Property Sheet->Data->Recordsource, select "tool implementation" from th drop down.
your form now is Bound to table, tool implementation
on the Ribbon->Design->Add existing fields, drag [Date] field to your form.
now change the code to:
Code:
Private Sub Delivered_AfterUpdate()
    If Delivered = -1 Then  _
    Me![date] = Now()
End Sub
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 01:00
Joined
Oct 29, 2018
Messages
21,455
I'm new access and I don't know what you mean by bound. The date and checkbox are from the same table but I don't want to have the date field on the form.
Hi. You're original code tries to update the date when the user checks the box. What do you want to happen if the user unchecks the same box?
 

hllary

Registered User.
Local time
Today, 01:00
Joined
Sep 23, 2019
Messages
80
arnelgp's code works.

When the user un-checks the checkbox the date is removed. Which is what I wanted.

Thank you for your help!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:00
Joined
Oct 29, 2018
Messages
21,455
arnelgp's code works.

When the user un-checks the checkbox the date is removed. Which is what I wanted.

Thank you for your help!
Hi. Glad to hear you got it working. Good luck with your project.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:00
Joined
May 7, 2009
Messages
19,230
then you need to revise the code:
Code:
Private Sub Delivered_AfterUpdate()
    Me![date] = IIF( Me.Delivered, Now(), Null)
End Sub
 

Users who are viewing this thread

Top Bottom