mrmozambique
Registered User.
- Local time
- Tomorrow, 01:46
- Joined
- May 20, 2009
- Messages
- 16
Hi all. Searched everywhere, but I don't seem to understand the meaning of this error. I'm trying to create a warning message box if the user tries to enter a duplicate record (but still allow it). My code is below. The error occurs when I try to set rcst equal to the recordset of rslt (code: Set rcst = dbs.OpenRecordset(rslt, dbOpenSnapshot)). Any ideas?
Code:
'Check to see if Facility has already had shipment this cycle. If so, give a warning.
Dim dbs As DAO.Database
Dim rslt As String
Dim answer As Integer
Dim rcst As DAO.Recordset
Set dbs = CurrentDb
rslt = "SELECT eDeliveries.DispCycle, eDeliveries.FacilityID FROM eDeliveries WHERE (((eDeliveries.DispCycle)=[Forms]![fDispatch]![fDispatchsub]![txtDispCycle]) AND ((eDeliveries.FacilityID)=[Forms]![fDispatch]![fDispatchsub]![cbFacilityID]));"
Set rcst = dbs.OpenRecordset(rslt, dbOpenSnapshot) ' [COLOR=DarkOrange]THIS IS WHERE THE ERROR OCCURS[/COLOR]
If rcst.EOF Then
answer = MsgBox("This facility already had a shipment this cycle. Do you wish to continue?", vbYesNo)
If answer = vbNo Then
Cancel = True
Me.cbFacilityID.SetFocus
End If
Else
End If