R
RipperT
InmateId is a text field on a form...
Private Sub InmateId_AfterUpdate()
Dim incomingId, outgoingId, newName
With Me
incomingId = .InmateId
outgoingID = .InmateId.OldValue
newName = DLookup("LstName", "tblInmates", _
"[InmateId] = '" & .InmateId.Value & "'")
If IsNull(DLookup("InmateId", "tblLockAllocations", _
"[InmateId] = '" & .InmateId & "'")) Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , _
acMenuVer70
MsgBox .InmateId.Value & " " & newName & " is now on count. "
write_history incomingId:=incomingId
End If
End With
End Sub
Private Sub write_history(Optional outgoingId As Variant, Optional
incomingId As Variant)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Dim strOutgoingSQL
strOutgoingSQL = "SELECT TransactionID, InmateID, HousingUnit, CellNo,
Bunk," _
& "DateTimeOut, OutUser " _
& "FROM tblLockHistory WHERE tblLockHistory.InmateId = '" & outgoingId&
"' AND " _
& "tblLockHistory.DateTimeOut Is Null"
With Me
If Not IsMissing(outgoingId) Then
Set rs = db.OpenRecordset(strOutgoingSQL)
'Find only that record where that inmate last moved in
'and add a move-out date to the DateTimeOut field
If rs.RecordCount = 1 Then
rs.Edit
rs!DateTimeOut = Now
rs!OutUser = [CurrentUser]
rs.Update
Else:
'add new record to tblLockHistory
rs.AddNew
[...]
End If
End If
End Sub
The call to write_history is causing a Type Mismatch error 13 at the
strOutgoingSQL assignment statement. I've tried everything I can think of. I
have another call to write_history in this sub that calls another sub that
calls write_history and it works fine; I've tried taking cues from that sub
and fiddling with it, but I can't come up with anything. This is the cleaned
up version of what I actually have, so if I've hosed it up, sorry. I'll
clarify anything that needs it, just please help, it's driving me nutz...
Rip
Private Sub InmateId_AfterUpdate()
Dim incomingId, outgoingId, newName
With Me
incomingId = .InmateId
outgoingID = .InmateId.OldValue
newName = DLookup("LstName", "tblInmates", _
"[InmateId] = '" & .InmateId.Value & "'")
If IsNull(DLookup("InmateId", "tblLockAllocations", _
"[InmateId] = '" & .InmateId & "'")) Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , _
acMenuVer70
MsgBox .InmateId.Value & " " & newName & " is now on count. "
write_history incomingId:=incomingId
End If
End With
End Sub
Private Sub write_history(Optional outgoingId As Variant, Optional
incomingId As Variant)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Dim strOutgoingSQL
strOutgoingSQL = "SELECT TransactionID, InmateID, HousingUnit, CellNo,
Bunk," _
& "DateTimeOut, OutUser " _
& "FROM tblLockHistory WHERE tblLockHistory.InmateId = '" & outgoingId&
"' AND " _
& "tblLockHistory.DateTimeOut Is Null"
With Me
If Not IsMissing(outgoingId) Then
Set rs = db.OpenRecordset(strOutgoingSQL)
'Find only that record where that inmate last moved in
'and add a move-out date to the DateTimeOut field
If rs.RecordCount = 1 Then
rs.Edit
rs!DateTimeOut = Now
rs!OutUser = [CurrentUser]
rs.Update
Else:
'add new record to tblLockHistory
rs.AddNew
[...]
End If
End If
End Sub
The call to write_history is causing a Type Mismatch error 13 at the
strOutgoingSQL assignment statement. I've tried everything I can think of. I
have another call to write_history in this sub that calls another sub that
calls write_history and it works fine; I've tried taking cues from that sub
and fiddling with it, but I can't come up with anything. This is the cleaned
up version of what I actually have, so if I've hosed it up, sorry. I'll
clarify anything that needs it, just please help, it's driving me nutz...
Rip