Hi, i am trying to update a loginout table with the date/time out but i am getting an item not found in this collection message - here is the code.
Dim MyDB As DAO.Database
Dim rsLogout As DAO.Recordset
Dim MyQuery0 As DAO.QueryDef
Dim strSQL As String
Dim stDocName As String
Dim stLinkCriteria As String
Set MyDB = CurrentDb()
' Define all of the queries to be used in the procedure
'
' Retrieve tbl_Logins record
strSQL = "PARAMETERS parmLogin long; " & _
"SELECT tbl_Logins.LoginID " & _
"FROM tbl_Logins " & _
"WHERE tbl_Logins.LoginID = [parmLogin] "
Set MyQuery0 = MyDB.CreateQueryDef("", strSQL)
MyQuery0("parmLogin") = Forms!frmMainStartup!txtLoginID
Set rsLogout = MyQuery0.OpenRecordset()
If rsLogout.BOF And rsLogout.EOF Then
MsgBox "Could not insert Logout data, please notify your manager!"
rsLogout.Close
DoCmd.Quit
Else
'if tbl_Logins record found then update it with logout info
rsLogout.Edit
rsLogout("DateOut") = Now()
rsLogout("TimeOn") = Format(Now(), "Short Time") - Format(rsLogout!DateIn, "Short Time")
rsLogout.Update
rsLogout.Close
End If
DoCmd.Quit
it seems to find the record - i stored the recordid on the login screen
but i cant do the rsLogout.update?? i get the item not found in this collection
if you can help thanks very much!
Dim MyDB As DAO.Database
Dim rsLogout As DAO.Recordset
Dim MyQuery0 As DAO.QueryDef
Dim strSQL As String
Dim stDocName As String
Dim stLinkCriteria As String
Set MyDB = CurrentDb()
' Define all of the queries to be used in the procedure
'
' Retrieve tbl_Logins record
strSQL = "PARAMETERS parmLogin long; " & _
"SELECT tbl_Logins.LoginID " & _
"FROM tbl_Logins " & _
"WHERE tbl_Logins.LoginID = [parmLogin] "
Set MyQuery0 = MyDB.CreateQueryDef("", strSQL)
MyQuery0("parmLogin") = Forms!frmMainStartup!txtLoginID
Set rsLogout = MyQuery0.OpenRecordset()
If rsLogout.BOF And rsLogout.EOF Then
MsgBox "Could not insert Logout data, please notify your manager!"
rsLogout.Close
DoCmd.Quit
Else
'if tbl_Logins record found then update it with logout info
rsLogout.Edit
rsLogout("DateOut") = Now()
rsLogout("TimeOn") = Format(Now(), "Short Time") - Format(rsLogout!DateIn, "Short Time")
rsLogout.Update
rsLogout.Close
End If
DoCmd.Quit
it seems to find the record - i stored the recordid on the login screen
but i cant do the rsLogout.update?? i get the item not found in this collection
if you can help thanks very much!