S
Stacey
I wrote a function that will take a value and compare it
to the values of a record in a query I have created. When
the compiler reaches the record in the query I want to
compare too, I get an item not found in collection
message. I am not sure what I am doing wrong. Here is
the function I have coded and the item not found in
collection is rec!badge_#:
Public Function CheckOpenLog(db As Database, qry As
QueryDef, frm As Form, badgenumber As Integer) As Integer
Dim badge As Integer
badge = badgenumber
Dim rec As Recordset
Set qry = db.QueryDefs("BadgesOut")
Set rec = qry.OpenRecordset()
DoEvents
Do While Not rec.EOF
If badge = rec!Badge_# Then
MsgBox ("This badge is still in use, log out
before reissuing!"), vbOKOnly, "Card Issuing Error"
Exit Function
End If
rec.MoveNext
Loop
End Function
to the values of a record in a query I have created. When
the compiler reaches the record in the query I want to
compare too, I get an item not found in collection
message. I am not sure what I am doing wrong. Here is
the function I have coded and the item not found in
collection is rec!badge_#:
Public Function CheckOpenLog(db As Database, qry As
QueryDef, frm As Form, badgenumber As Integer) As Integer
Dim badge As Integer
badge = badgenumber
Dim rec As Recordset
Set qry = db.QueryDefs("BadgesOut")
Set rec = qry.OpenRecordset()
DoEvents
Do While Not rec.EOF
If badge = rec!Badge_# Then
MsgBox ("This badge is still in use, log out
before reissuing!"), vbOKOnly, "Card Issuing Error"
Exit Function
End If
rec.MoveNext
Loop
End Function