Form checkbox updates date in another table

hllary

Registered User.
Local time
Today, 08:58
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
 
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?
 
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.
 
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:
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?
 
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!
 
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.
 
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

Back
Top Bottom