logon tracking question

J

JohnE

I have a logon form in which the person selects their name
and then types in their password. Does someone know of a
way to capture this info and record it into a table when
some signs on to the db? If there is an example to see,
that is good to.
Thanks.
*** John
 
V

Van T. Dinh

After your code checking the UserName and Password, you
can use an Append Query to append a new Record with the
data on the Form to the Table tblLogOn.

If you use DAO, I would expect the code to be something
like:

****Untested****
Dim strSQL As String
strSQL="INSERT INTO tblLogOn (UserID, LogOnDateTime) " & _
" VALUES (" & Me.txtUserID & ", Now())"
CurrentDB.Execute strSQL, dbFailOnError
********

(assuming UserID is numeric).

HTH
Van T. Dinh
MVP (Access)
 
T

Tom Wickerath

Hi John,

I assume you have a command button on your form, which your user clicks after selecting their
name and entering their password. You can add code to the click event procedure of this button to
do this. Here are the steps required to do this.

1.) Open a recordset using the table you wish to save this information into. If you are saving
the data in a JET database, then you can use DAO code.
2.) Use the .AddNew method to add a new record.
3.) Interrogate the value selected in the combo box and set your field equal to this value.
For example:
rs("UserID") = cboSelectUser
rs("LoginTime") = Now()

where UserID is a field in the table used to store the selected value in the combo box
cboSelectUser, and LoginTime is a Date/Time field in the same table.
4.) Use the .Update method to save the new record
5.) Close the recordset and set it equal to nothing

A more specific example would require additional information, such as the names of the combo box
and command button, the name of the table that you wish to store the data into, and the names &
datatypes of the fields in this table.

Tom
_______________________________________________


I have a logon form in which the person selects their name
and then types in their password. Does someone know of a
way to capture this info and record it into a table when
some signs on to the db? If there is an example to see,
that is good to.
Thanks.
*** John
 
Top