Close Form Set Table Control To Date Now

D

Dave Elliott

I would like to know how to on the On Close Event of my form, named
frm_ExitNow make the control in my table
named tblLastUsed (LastUsed) is the control name change to the Date(),
which is the default value.
 
N

Nikos Yannacopoulos

Dave,

You are not very clear on your table and how you use it. If I understand
correctly, table tblLastUsed has only one field, LastUsed... but will it
always have just one record holding the last timestamp, or do you want a new
one added every time, so it holds a history of logoffs? Here's what the code
behind the button should look like in each case:

Overwrite the one existing record:

strSQL = "UPDATE tblLastUsed SET LastUsed = " & Now()
CurrentDB.Execute strSQL

Or, to add a bnew record every time:
strSQL = "INSERT INTO tblLastUsed ( LastUsed ) SELECT "& Now() & " AS
TimeStamp"
CurrentDB.Execute strSQL

HTH,
Nikos
 
Top