Auto-fill question

cbearden

Registered User.
Local time
Today, 15:57
Joined
May 12, 2004
Messages
84
I have a subform and when the controls on it are updated, changed from previous info, then I need a control(called dtmUpdate) to show the current date (=Date()).

How would I go about doing this?

Thank you
 
I'm not sure I follow what it is you need. If it is a date stamp on this record then all you need is [DateStampField] = Date() in the BeforeUpdate event of the SubForm.
 
I have the following fields:

Name
Contact
Phone
Fax

The Name control will be a combo box that someone will pull up info by. When that info comes up(Contact, PHone, Fax) and it is outdated...then the user will change it. That's when I need the Updated control to be filled with the current date.

Would this still be BeforeUpdate? I don't want a new date to appear unless a change is made. And not just a backspace and type the same letter.

Thanks
 
I would expect you also have a field in the table to which "dtmUpdate" is bound. If you can live with the side effect of selecting the current control then put this in the BeforeUpdate event of each control:

Code:
Private Sub txtName_BeforeUpdate(Cancel As Integer)

If Me.txtName = Me.txtName.OldValue Then
   Me.Undo
End If

End Sub
Don't forget to use the names of your controls and not my dummy names!

The BeforeUpdate event of the form *only* fires when an update is required. Therefore you will not get a new DateTime stamp unless an update takes place.

In thinking about it, I would recommend using Now() rather than Date() so you will pick up the time component in your DateTime stamp.
 
In order to do all controls, would I do this...

If ....

End If

OR

If...

End IF

OR...

or is OR not necessary.

Thanks for your help!
 
The code I posted would have to be in the BeforeUpdate event of each of your controls. No If...Else...End If involved.
 

Users who are viewing this thread

Back
Top Bottom