Capturing User Name and Form Closing

  • Thread starter Thread starter John
  • Start date Start date
J

John

I need some help with a confidentiality form I have when
users access the database. The form has a subform that
captures the network logon of the user and also has the
date/time they opened the database. The form also has an
Agree and Disagree button for the user.
How can I write that info to a table to keep track of
users in the database. I don't want to set up separate
user accounts, it will be too much of a hastle to do that.
Also, how do I close the confidentiality form when the
user clicks agree and then open the other form. I have it
coded so it opens another form but the confidentiality
screen stays open in the back ground.
Any suggestions will be very helpful.

TIA,

John
 
I need some help with a confidentiality form I have when
users access the database. The form has a subform that
captures the network logon of the user and also has the
date/time they opened the database. The form also has an
Agree and Disagree button for the user.
How can I write that info to a table to keep track of
users in the database. I don't want to set up separate
user accounts, it will be too much of a hastle to do that.

Assuming that it's only going to let them into the database if they
click the Agree button, you can have code in the cmdAccept_Click()
event that will save the user name and date/time to a table in the
database.

1 - Create a table called tblAccessedBy. Have fields for username and
date
2 - In the click event of the Agree button, you can do something like
this:

PSEDO-CODE

Dim strSQL as String

strSQL = "INSERT INTO tblAccessedBy (WhichUser, DateAccessed) VALUES
('" & strUserName & "', #" & dtmDateAccessed &"#"

CurrentDb.Execute(strSQL)

Replacing strUserName and dtmDateAccessed with the appropriate
variables that you said you already store.

Also, how do I close the confidentiality form when the
user clicks agree and then open the other form. I have it
coded so it opens another form but the confidentiality
screen stays open in the back ground.
Any suggestions will be very helpful.

You can use a docmd.close after the other form is open to close the
current one. That is unless you open the other form as modal - in
which case the code on the existing form halts. So instead, you could
close your Agreement Form from the Form_Open event of the second form.

docmd.Close acForm, "frmConfidentiality"\


-D
 
Back
Top