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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto date entry in field

Status
Not open for further replies.

kvest

Technical User
Jan 10, 2005
62
US
I have a data entry form that has a text box for entry of that date a report was approved. Currently, operators have to manually enter the date (mm/dd/yyyy). How could I automate this by using the Now() function (or something else) so that when operator tabs into the box, it is automaticly populated with the current system date?

As a side benefit, if it is possible for this date to overwritten in case someone approved a report on a prior day and did not enter it until a different date.
 
Hi
If you are working with new records, you could set the Default Value to Date() or Now() - Now() includes time, Date() does not. This can be changed by the user. Alternatively, you could use the OnEnter event to set the date if it is null or blank.
 
kvest,
Format the text box to a date type; Short, Med or Long. In the "default" property of the textbox type:
=Date()
 
That did it!!!! I knew it was something easy...but findout out where/how to put it in is the question.

Thanks
 
That did it!!!! I knew it was something easy...but finding out where/how to put it in is the question.

Thanks
 
kvest:

Once entered, I would assume you need the date to remain unchanged. Is that correct? If so, with Date() and Now() I fear they will update each time you open the form. I suspect having the current date entered automatically and then "locked in" is going to be a little complicated (you may miss the days of manual entry!
bigsmile.gif
)

Good luck!
Tim
 
SilentAiche,
That is correct....I would like it entered when the record is created and then not changed. Generally once the form is created, it is only viewed after that, but I am pretty new at this so I may be incorrect. Is there a way to set it so that it only enters the Date() when the record is created? Would that avoid this?
 
I just changed the system date on my computer then when back and viewed a couple of records I entered after this change. The date appears to only be entered when a new record is created. Users can scroll through and view the existing records without the approved date being changed.

I think I am in good shape. Thanks for the warning..that would have been a disaster.
 
kvest,

Knowledge-wise, I am in that frustrating middle-gound where I can identify more problems than I can solve. This, I'm afraid, is one of those cases. Fortunately, someone on this forum is bound to have the answer. You might also search the forum for previous FAQs or threads that might have addressed this.

Good luck!
Tim
 
Hi
As I said earlier
If you are working with new records, you could set the Default Value to Date()
That is, setting a default value only creates a date on a new record. It does not create a date on an existing record, even if the date is blank.
Hope this clarifies the point.
Have Fun!
 
kvest,

That's really curious. When I changed my system date, the date field in my test database updated each time whether I was using Date() or Now() (which are you using, by the way)?. When I scrolled through records that already had a date, they updated every time. You might want to test some more to be completely sure. I suppose it's possible that there could be a property or option setting so that your form doesn't update, but I'd be a little surprised.

I'm using Access 2002 on Win XP, by the way.

Tim
 
blush.gif

Remou:

By golly, you did say Default Date - I missed that detail completely. I've got to look into that whole "learning to read" thing - I've been waiting see if it's just a fad.

My testing, of course, was using =Date() in the text box. Kvest obviously followed your actual instructions, in the manner that you clearly wrote them, and that's why his testing and mine had different results.

Apologies to all for identifying a non-existent problem, and thanks to Remou for setting me straight. Can I go home now()?

T i m (harder to sign than most...)
blush.gif
 
Snicker, Snicker. Could happen to a bishop (other major religious figure of your choice) :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top