Close button document time

LVN

New member
Local time
Today, 08:25
Joined
Apr 10, 2006
Messages
7
The DB Im working on is going to be secured.
I've created user ids with passwords.
I want to create a close button and have it document the time in a table.
Log in/out.
Please help.
 
You can use the now() function to record the current date and time.
 
You can use the now() function to record the current date and time.
 
Thanks,
how can I put that in the 'close' button on the form.
I have a table called 'UserOut'
fields: Userpw;Date/timeOut(I put Now());SSN
This table is to record when the user logs out.
 
Use an update or append query [SQL] to update or add the record that will store the information.

You should have one table that stores the user in/out information.
 
You will need to write a procedure to add a new record to your table.

Dim myRec as dao.recordset

set myRec=currentdb.openrecordset("NameOfTable")

myRec.addnew
myRec.fields("UserName")=CurrentUser
myRec.fields("TimeOut")=Now
myRec.update


Something like above would do the trick!!
 
I added a DateLeft field to my 'UserInput' table.
Fields are: userpw;DateEntered;DateLeft;SSN
When the user logs on with a user id and password. The password is loged into this table along with the date and time entered.
I want it to record the date and time in the same row in the 'DateLeft' field when the user clicks the button on the form 'Close' (to log time out)

1. I created an update query to update field 'DateLeft' to Now()
2. Created a macro to run the query when they click 'close', then quit. When the user clicks close..... it states you have 1 record to append or something like that. but doesn't exit the db after that.

To the point:
How can I make the update query update the 'DateLeft' without adding a new record to tie with the userpw?

How can I have the close button run the query and exit the app?

PS. I new to Access, please be gentle.

Thanks or your help!
 
Add this code to the on_click of your exit button, Which will prompt the user if the want to exit, if confirmed then the query is run without warning and the application then closed.

Private Sub btnClose_Click()

Dim Answer As Integer
Dim myRec as dao.recordset

Answer = MsgBox("Do you wish to exit the database?", vbYesNo + vbQuestion + vbDefaultButton1, "Application Title")

If Answer = vbYes Then

DoCmd.SetWarnings False

set myRec=currentdb.openrecordset("NameOfTable")
myRec.addnew
myRec.fields("UserName")=CurrentUser
myRec.fields("TimeOut")=Now
myRec.update

DoCmd.SetWarnings True

DoCmd.Quit
Else

End If
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom