Hi All.
I have introduced a login screen to my database which requires a username and password to be entered. After logging in successfully, an Intro Page opens which displays the current user that is logged in.
I done this by putting the following code behind the login button:
TempVars!tvarUser = Me!Txt_username.Value
Txt_Username being the textbox that displays the username that is entered on login.
On the Intro Page I want to now add a button that adds a new record to a table which will keep track of all users that have logged in and store the time of the login.
I have been able to add a new record using the following code:
Private Sub Cmd_iaccept_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_userrecord")
rs.AddNew
rs.Fields("username") = "newuserid"
rs.Fields("DateTime") = "11/09/21"
rs.Update
End Sub
This code currently adds a new record to the table, but I want to add the username that is displayed in the txt_username box. Currently it just adds a new record with newuserid in the username field. I also want to be able to store the current date and time in the DateTime field.
Would anybody be able to assist?
Thanks
I have introduced a login screen to my database which requires a username and password to be entered. After logging in successfully, an Intro Page opens which displays the current user that is logged in.
I done this by putting the following code behind the login button:
TempVars!tvarUser = Me!Txt_username.Value
Txt_Username being the textbox that displays the username that is entered on login.
On the Intro Page I want to now add a button that adds a new record to a table which will keep track of all users that have logged in and store the time of the login.
I have been able to add a new record using the following code:
Private Sub Cmd_iaccept_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_userrecord")
rs.AddNew
rs.Fields("username") = "newuserid"
rs.Fields("DateTime") = "11/09/21"
rs.Update
End Sub
This code currently adds a new record to the table, but I want to add the username that is displayed in the txt_username box. Currently it just adds a new record with newuserid in the username field. I also want to be able to store the current date and time in the DateTime field.
Would anybody be able to assist?
Thanks