Hi All
I have this simple code:
Code:
Set rs = CurrentDb.OpenRecordset("dbo_Users_Table", dbOpenDynaset, dbSeeChanges)
rs.Edit
rs!LastLogin = Now()
rs.Update
This is just a simple line to record when I user logs in.
So sometimes this works, and sometimes it doesnt (no errors), sometimes it just doesnt seem to change to the new Now() date / time?
Any ideas?
I do use rs previously above this code, so maybe that might cause it? Full code as below:
Code:
Private Sub cmdLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("dbo_Users_Table", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "UserName='" & Me.txtUserName & "'"
If rs.NoMatch = True Then
IncorrectUserNameStyle
Exit Sub
End If
If rs.NoMatch = True Then
IncorrectUserNameStyle
Exit Sub
Else
Me.lblIncorrectUserName.Visible = False
Me.txtUserName.BorderColor = RGB(0, 0, 0)
End If
If rs("UserPassword") <> Nz(Me.txtPassword, "") Then
IncorrectPasswordStyle
Exit Sub
Else
Me.lblIncorrectPassword.Visible = False
Me.txtPassword.BorderColor = RGB(0, 0, 0)
End If
MsgBox "Login Successful" & vbNewLine & vbNewLine & "Program will now load and update, this will take some time.", vbInformation, "Logged In As " & Me.txtUserName
strSecLevel = rs("SecLevel")
Set rs = CurrentDb.OpenRecordset("dbo_Users_Table", dbOpenDynaset, dbSeeChanges)
rs.Edit
rs!LastLogin = Now()
rs.Update
Call UpdateFromSQL
DoCmd.OpenForm "Test Form"
DoCmd.Close acForm, Me.Name
End Sub
EDIT: Sorry I think I figured this out, because I reset the RS, it doesnt keep the correct login row as the previous use, so I need to do the FindFirst again.