vb Code:
'Find the last login date of the username
Set RecSet2 = New ADODB.Recordset
RecSet2.CursorLocation = adUseClient
RecSet2.Open "tblAccess", sConn, adOpenStatic, adLockOptimistic, adCmdTable
RecSet2.Find "Username = '" & ThePerson & "'", , adSearchBackward
Me.lblLastLogin.Caption = Me.lblLastLogin.Caption & RecSet2.Fields("TheDate") & "at" & RecSet2.Fields("TheTime")
Should be replaced by this:
vb Code:
'Find the last login date of the username
Set RecSet2 = New ADODB.Recordset
Dim strSQL as String 'not really needed, but makes the code easier to read & debug
strSQL = "SELECT * FROM tblAccess WHERE Username = '" & ThePerson & "'"
RecSet2.Open strSQL, sConn, adOpenForwardOnly, adLockReadOnly, adCmdText
Me.lblLastLogin.Caption = Me.lblLastLogin.Caption & RecSet2.Fields("TheDate") & "at" & RecSet2.Fields("TheTime")
'Unless you want to corrupt your database, you need to close
'recordsets & connections when you finish with them:
RecSet2.Close
Set RecSet2 = Nothing
This still isn't quite right, but is much closer to what you need - all we need to do is minor changes to the SQL statement.