Hi All,
I've created a simple login form that pops up when the Access database opens. I've followed the instruction of a tutorial on youtube.
The login is a simple form with a User Name and a Password. The code compares the name and password with the data in a specific table.
The Vb code I copied is :
Private Sub ButtonLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tbl_Administrator", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "UserName='" & Me.TXTUserName & "'"
If rs.NoMatch = True Then
Me.lblIncorrectUserName.Visible = True
Me.TXTUserName.SetFocus
Exit Sub
End If
Me.lblIncorrectUserName.Visible = False
If rs!Password <> Me.txtPassword Then
Me.lblIncorrectPassword.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblIncorrectPassword.Visible = False
DoCmd.OpenForm "OPT database"
DoCmd.Close acForm, Me.Name
End Sub
I copied and pasted this code in the "on click" event of a login button. This code works perfectly.
My problem : I would like to automatically update the date and time the user logs in.
I've created a table (tbl_Administrator) withh 4 columns (Username, Password, Update, UpTime).
I tried adding rs.fileds("Update")= Date and rs.Fields("UpTime")=Time just before the "End Sub".
It doesn't work. Does anyone have an idea how to finish the VB code, to automatically update the Date and time the user logs in?
Thank you for your help.
Mat
I've created a simple login form that pops up when the Access database opens. I've followed the instruction of a tutorial on youtube.
The login is a simple form with a User Name and a Password. The code compares the name and password with the data in a specific table.
The Vb code I copied is :
Private Sub ButtonLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tbl_Administrator", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "UserName='" & Me.TXTUserName & "'"
If rs.NoMatch = True Then
Me.lblIncorrectUserName.Visible = True
Me.TXTUserName.SetFocus
Exit Sub
End If
Me.lblIncorrectUserName.Visible = False
If rs!Password <> Me.txtPassword Then
Me.lblIncorrectPassword.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblIncorrectPassword.Visible = False
DoCmd.OpenForm "OPT database"
DoCmd.Close acForm, Me.Name
End Sub
I copied and pasted this code in the "on click" event of a login button. This code works perfectly.
My problem : I would like to automatically update the date and time the user logs in.
I've created a table (tbl_Administrator) withh 4 columns (Username, Password, Update, UpTime).
I tried adding rs.fileds("Update")= Date and rs.Fields("UpTime")=Time just before the "End Sub".
It doesn't work. Does anyone have an idea how to finish the VB code, to automatically update the Date and time the user logs in?
Thank you for your help.
Mat