C
Cheryl Bender
I am completely stumped. This was working yesterday.
The code searches for the barcode entered to confirm it is associated
with a required record. What is happening now is that FindFirst
returns a record that doesn't match the one searched and returns EOF =
false. I have tried decompiling, moving the code to a different
module, compact and repair, but cannot explain this behavior. If I
take the where statement and put it in a query it returns no records
(which it should since the barcode is not associated) but when I do
FindFirst it returns the wrong record. I have other code in the same
database that uses FindFirst and seems to be working fine. The only
thing I can think to do is add code that will verify the record found
matches the one searched, but it just doesn't seem right. Thanks.
Public Function CheckVial(pstrVial As String, pstrLot As String,
pstrCASNo As String) As Boolean
On Error GoTo CheckVial_Err
Dim recCheckVial As Recordset
Set recCheckVial = CurrentDb.OpenRecordset("qryVialBarcodeCASNo")
recCheckVial.FindFirst "Vialbarcode = """ & pstrVial & """"
If Not recCheckVial.EOF Then
pstrLot = recCheckVial!lot
pstrCASNo = recCheckVial!CASNo
CheckVial = True
Else
CheckVial = False
End If
.....'error handling code removed
End Function
The code searches for the barcode entered to confirm it is associated
with a required record. What is happening now is that FindFirst
returns a record that doesn't match the one searched and returns EOF =
false. I have tried decompiling, moving the code to a different
module, compact and repair, but cannot explain this behavior. If I
take the where statement and put it in a query it returns no records
(which it should since the barcode is not associated) but when I do
FindFirst it returns the wrong record. I have other code in the same
database that uses FindFirst and seems to be working fine. The only
thing I can think to do is add code that will verify the record found
matches the one searched, but it just doesn't seem right. Thanks.
Public Function CheckVial(pstrVial As String, pstrLot As String,
pstrCASNo As String) As Boolean
On Error GoTo CheckVial_Err
Dim recCheckVial As Recordset
Set recCheckVial = CurrentDb.OpenRecordset("qryVialBarcodeCASNo")
recCheckVial.FindFirst "Vialbarcode = """ & pstrVial & """"
If Not recCheckVial.EOF Then
pstrLot = recCheckVial!lot
pstrCASNo = recCheckVial!CASNo
CheckVial = True
Else
CheckVial = False
End If
.....'error handling code removed
End Function