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!

Date Field question 2

Status
Not open for further replies.

Rene1024

MIS
Jul 24, 2003
142
0
0
US
Hello,

I have a form with two date fields, they both have auto date stamp properties (Date()), so whenever the form is opened the fields get updated automatically to the current date on the PC.
I would like to have one of the fields update only once (when the record is created) and if the record is pulled up again I want to maintain the date that was assigned when the record was created instead of the new date on the pc.

Please let me know how i can accomplish this.

Rgds.

Rene.
 
I'm not familiar with "auto date stamp" but don't use it.

Instead in your table specify Date() (or Now()) as the default value of the field. If you for some reason don't want it on the table, you can specify the default value of the control on the form instead.
 

lameid's suggestion will certainly work in this case, but just so you know how to do something only when a new record is involved, here's another way:

Code:
Private Sub Form_Current()
  If Me.NewRecord Then
    Me.DateToBeMaintained = Date
  End If 
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks for all your help. I'm a little confused though.
Here's what I have:
When the form loads I've applied the following:
Private Sub Form_Load()

Me.RecordEntered.Value = Date


End Sub
---------------------------------------------
And on Current I have:

Private Sub Form_Current()

If Me.NewRecord Then
Me.RecordEntered = Date

End If


End Sub
-----------------------------------------------------
I create a new record and the current date gets applied, which is fine, but if i change the date on my PC and open the existing record the new date replaces the old date.
What am I missing?

Rgds.

Rene.
 
You don't need the form on load event at all.
 
Perfect!

Thank you and have a great weekend.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top