Enter Todays Date Automatically

  • Thread starter Scott_66701 via AccessMonster.com
  • Start date
S

Scott_66701 via AccessMonster.com

How can I get a textbox to automatically enter todays date and record it in
the current record when it is saved?. Also is there a way to put a persons
age into the "age textbox" from the information entered in the "DOB textbox",
and have it saved to the record too.

Thanks
 
J

John W. Vinson

How can I get a textbox to automatically enter todays date and record it in
the current record when it is saved?.

Set its Default Value property (either in the table, or the default of a
textbox on your data entry form) to

=Date()

If you want the date and time (to the second), use

=Now()

instead.
Also is there a way to put a persons
age into the "age textbox" from the information entered in the "DOB textbox",
and have it saved to the record too.

Don't store the age AT ALL. Any age you save in a table will - with absolute
certainty - be WRONG within one year, and it wastes space. Just recalculate it
whenever you need it. Computers do calculations really really fast...

Set the control source of the age textbox (on your form, or on a report) to

=DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") > Format(Date(),
"mmdd", 1, 0)

or use the same expression as a calculated field in a query.
 
J

Joseph Atie

John,

Any reason this wouldnt work?

ive used the date function to autofill forms many times in the past, but on
this current project it refuses to work.

If i use it on a bound text box i get a blank box, if i use it on an unbound
text box i get #Name?

I cant fiigure olut why this is, I know it should work

HELP please

Regards

Joseph Atie


John W. Vinson said:
How can I get a textbox to automatically enter todays date and record it in
the current record when it is saved?.

Set its Default Value property (either in the table, or the default of a
textbox on your data entry form) to

=Date()

If you want the date and time (to the second), use

=Now()

instead.
Also is there a way to put a persons
age into the "age textbox" from the information entered in the "DOB textbox",
and have it saved to the record too.

Don't store the age AT ALL. Any age you save in a table will - with absolute
certainty - be WRONG within one year, and it wastes space. Just recalculate it
whenever you need it. Computers do calculations really really fast...

Set the control source of the age textbox (on your form, or on a report) to

=DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") > Format(Date(),
"mmdd", 1, 0)

or use the same expression as a calculated field in a query.
 
J

John W. Vinson

ive used the date function to autofill forms many times in the past, but on
this current project it refuses to work.

If i use it on a bound text box i get a blank box, if i use it on an unbound
text box i get #Name?

This appears to be the very common References bug. Open any
module in design view, or open the VBA editor by typing
Ctrl-G. Select Tools... References from the menu. One of the
..DLL files required by Access will probably be marked
MISSING. Uncheck it, recheck it, close and open Access.

If none are MISSING, check any reference; close and open
Access; then uncheck it again. This will force Access to
relink the libraries.
 

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