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

Add Time Stamp to Every Record

Status
Not open for further replies.

RandDUser

Technical User
Feb 24, 2005
65
0
0
US
I have a form that has a date field in it. All the date fields are blank, and I want to time stamp them. I have the following code through a command button:

Me.TEXTBOX_DATE.Value = Date

However, this only inserts the time for the first record and not all of them. My guess is it needs a loop, but I've never used that before. Any help is appreciated. Thanks!
 
When is this "time stamp" being applied? When the record is created? If that is the case, in the table there is a property called default value. Set this to: =Now()

Also, Date() gives todays date, where Now() also includes the time if you did not know the distinction.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
The records have already been created. I need to time stamp existing records. Let's say I have 10,000 records, and the DATE field is blank for every record. Then the query is run to pull back 300 records. Those 300 records need to have the 'time stamp' (Date Stamp in this case).
 
How are ya RandDUser . . .

Have a look at [blue]Update Queries![/blue] for bulk updates.

For [blue]on the fly updates[/blue], in the [blue]Dirty[/blue] property of the form:
Code:
[blue]   Me![purple][b][i]DateFieldName[/i][/b][/purple] = Now()[/blue]
Every time a record is edited/added an update for that record occurs!

Bear in mind, [blue]Date[/blue] returns the date only, whereas [blue]Now()[/blue] returns date & time! (you can format the textbox for this).

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Ok....still not a difficult task. How are you getting the 300 records to display? I am assuming you are using a button or some such to apply a filter or filtering when opening the form.

You need to create an Update query that will update the records. Start by creating another Select query identical to the one you have for the data display. The change it to an Update query and set the UpdateTo line to: =Date()

Save this query with some name. Then depending on if you want the value changed before or after the records are display, use something like: DoCmd.OpenQuery "UpdateQueryName" in your code.

That should update the same group of records you are going to or just viewed, depending on the placement of the Update code.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
The On Dirty property wouldnt work for me, but the Update Query worked perfectly. Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top