Populate table fields when db is opened (1 Viewer)

Miff3436

Registered User.
Local time
Today, 21:53
Joined
May 27, 2015
Messages
23
Hi,

I have a table that has 3 fields in it, these are autoID, Date, and username. Is there a way that I can auto fill these fields each time the database is opened by a user.

I do not want any user input and for date I will set the default value to =Now(), the username to capture the Environ("username") and the autoID is just the auto number that will naturally increment each time the db is opened.

The reason for this is I want to build in a DLookup that will look at the last record to check the time it was last run as to whether or not a macro to import will run or not.

Thanks Miff 3436 (Using Access 2010)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:53
Joined
Aug 30, 2003
Messages
36,125
Execute an append query in the open event of the form that opens with the db. Or

Code:
CurrentDb.Execute "INSERT INTO TableName(FieldName) VALUES ('" & Environ("username") & "')"
 

Miff3436

Registered User.
Local time
Today, 21:53
Joined
May 27, 2015
Messages
23
Hi pbaldy,

The append query works perfectly, thank you for the quick response.

Miff3436
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:53
Joined
Aug 30, 2003
Messages
36,125
Happy to help!
 

Users who are viewing this thread

Top Bottom