Checkbox = True changes field in another table

hbrehmer

Member
Local time
Today, 03:41
Joined
Jan 10, 2020
Messages
78
Okay, I'm still learning and a bit confused how to make this work. I have a Yes/No unbound field on my form. When the user checks the box, I need a field in a table to change. The form is bound to Table1, but I need "Status" field in Table2 to update. How do I write this? Help!
 
Check out the second method here:


Thank you for this code, but that won't do what I need. The unbound check box should update a field for the same record in a different table. They are linked, so this should be easy, right?
 
Sorry, read too fast. Presuming the form can't be bound to a query that includes both, you can update it with SQL:

CurrentDb.Execute "UPDATE Table2 SET Status = 1 WHERE KeyField = " & Me.KeyField

If the status value is text it would need to be surrounded by single quotes.
 
Sorry, read too fast. Presuming the form can't be bound to a query that includes both, you can update it with SQL:

CurrentDb.Execute "UPDATE Table2 SET Status = 1 WHERE KeyField = " & Me.KeyField

If the status value is text it would need to be surrounded by single quotes.

I just want to confirm, this code will update only the record based on the the current record in my form? I don't want to change all the records in the 2nd table, just the one that is linked by the same ID number.
 
Yes, the WHERE clause should handle that, and Me.KeyField should pull the ID from the record you're on in the first form. Obviously you have to use the name of the control on your form that has that value.
 

Users who are viewing this thread

Back
Top Bottom