Update Main Form from changing Sub Form

G

Guest

I want to update a field in the main form (let's call it LastUpdated)if every
time I change a field in sub form (lets' call it FirstName) but have the hard
time to do it.

In the sub form, I click on FirstName property, click on On Change event for
VB Code Builder. I don't know how to code the line to update LastUpdated
field. Intellitimes doesn't help.

Please help. Thanks much.
 
J

John Vinson

I want to update a field in the main form (let's call it LastUpdated)if every
time I change a field in sub form (lets' call it FirstName) but have the hard
time to do it.

In the sub form, I click on FirstName property, click on On Change event for
VB Code Builder. I don't know how to code the line to update LastUpdated
field. Intellitimes doesn't help.

Please help. Thanks much.

Use the AfterUpdate event instead: the Change event is a bit
misleading, it fires *at every single keystroke*. I'm a bit concerned
about the requirement here: suppose the subform has 23 records? Should
the mainform LastUpdated reflect the most recent change to *any* of
the subform records?

If so, use code like this:

Private Sub FirstName_AfterUpdate()
Parent!LastUpdated = Now()
End Sub

or, use the subform's Form AfterUpdate event to flag the most recent
change to any field on the subform.


John W. Vinson[MVP]
 
G

Guest

It work!
Thank you so much. And Yes, if any change we have for any record on the sub
form should update the LastUpdated field.
Again, thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top