Add Date data is entered

  • Thread starter Thread starter Dan @BCBS
  • Start date Start date
D

Dan @BCBS

How can I make a field auto-populate the date??

My Database is linked to SQL tables.
I have a field called "Date Entered" that I would like to auto-populate the
date when the data (other fields) gets entered - then obviously retain that
date. I do not want it to keep changing to show the current date.

Suggestions??
 
Sub Form_AfterUpdate()

If Len([Date Entered] & vbNullString) = 0 Then
Me.[Date Entered] = Now
End If
End Sub

It may work in Before Update as well.
 
It also works on the ONLoad...

Question how can I change the format to only mm/dd/yyy
Currently it also shows time??

Thanks



Arvin Meyer said:
Sub Form_AfterUpdate()

If Len([Date Entered] & vbNullString) = 0 Then
Me.[Date Entered] = Now
End If
End Sub

It may work in Before Update as well.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Dan @BCBS said:
How can I make a field auto-populate the date??

My Database is linked to SQL tables.
I have a field called "Date Entered" that I would like to auto-populate
the
date when the data (other fields) gets entered - then obviously retain
that
date. I do not want it to keep changing to show the current date.

Suggestions??
 
Use Date instead of Now.

Also, you could use the Default Value of the control where the date is
carried.

=Date()
--
Dave Hargis, Microsoft Access MVP


Dan @BCBS said:
It also works on the ONLoad...

Question how can I change the format to only mm/dd/yyy
Currently it also shows time??

Thanks



Arvin Meyer said:
Sub Form_AfterUpdate()

If Len([Date Entered] & vbNullString) = 0 Then
Me.[Date Entered] = Now
End If
End Sub

It may work in Before Update as well.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Dan @BCBS said:
How can I make a field auto-populate the date??

My Database is linked to SQL tables.
I have a field called "Date Entered" that I would like to auto-populate
the
date when the data (other fields) gets entered - then obviously retain
that
date. I do not want it to keep changing to show the current date.

Suggestions??
 
Perfect- thanks

Klatuu said:
Use Date instead of Now.

Also, you could use the Default Value of the control where the date is
carried.

=Date()
--
Dave Hargis, Microsoft Access MVP


Dan @BCBS said:
It also works on the ONLoad...

Question how can I change the format to only mm/dd/yyy
Currently it also shows time??

Thanks



Arvin Meyer said:
Sub Form_AfterUpdate()

If Len([Date Entered] & vbNullString) = 0 Then
Me.[Date Entered] = Now
End If
End Sub

It may work in Before Update as well.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

How can I make a field auto-populate the date??

My Database is linked to SQL tables.
I have a field called "Date Entered" that I would like to auto-populate
the
date when the data (other fields) gets entered - then obviously retain
that
date. I do not want it to keep changing to show the current date.

Suggestions??
 
Are you looking for this to hold the date when the record is originally
created or do you want it to change if data is later edited?

Wouldn't using this is the OnLoad event only work on the first record to load,
if the field is empty? And assuming the form opens to a new record, would
about if create more than one record?

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
OnLoad works when you open a form. It seems that it might be better to stamp
the date/time when the record is complete. You can show only the date by
changing Now in the code to Date, but I'd prefer storing the timestamp as
well even if I choose only to display the date. You can display only the
date if you format the table and/or form to "short date".
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Dan @BCBS said:
It also works on the ONLoad...

Question how can I change the format to only mm/dd/yyy
Currently it also shows time??

Thanks



Arvin Meyer said:
Sub Form_AfterUpdate()

If Len([Date Entered] & vbNullString) = 0 Then
Me.[Date Entered] = Now
End If
End Sub

It may work in Before Update as well.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Dan @BCBS said:
How can I make a field auto-populate the date??

My Database is linked to SQL tables.
I have a field called "Date Entered" that I would like to auto-populate
the
date when the data (other fields) gets entered - then obviously retain
that
date. I do not want it to keep changing to show the current date.

Suggestions??
 
Back
Top