Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Date Field on Main Form when Changing Info in Sub Form

Status
Not open for further replies.

avaffa

Programmer
Jun 22, 2001
86
0
0
US
I have a form that contains a sub form. The "Last_Update" field is automatically updated with the current date on the main form whenever I change info in a record. I did this by using the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
LAST_UPDATE = Date
End Sub

Whenever I change info in the sub form, the "Last_Update" field on the main form is not updated. How can I get the "Last_Update" field to display the current date on the main form whenever I change info on the main form AND sub form? Thanks!
 
In the AfterUpdate Event Procedure of the SubForm you can put the following code:

Forms![MainFormName]![Last_Update] = Date()

Referring to controls from a Main Form to a subForm and visaversa can be confusing. Please refer to the explaination in this link to assist you in this type of VBA code:

Let me know how this works for you. Bob Scriver
 
The link to the VBA code helped a lot. Thanks!
 
I followed the above steps, but the date will not appear in the date field on the main form. Do I have to refresh the field somehow?
 
You might try a refresh or repaint to get the control to display.

Forms![MainFormName]![Last_Update].repaint
Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top