DLookup Action Cancelled?

Adzi

Registered User.
Local time
Today, 15:30
Joined
Jan 13, 2007
Messages
37
Hey,

I don't understand why my DLookup action is throwing up a run-time 2001: "You Cancelled the previous operation"

This line in question is this one;
Code:
BookingRefABC = DLookup("[Booking Reference]", "tblCampingBookings", "CustomerID='" & Me.Text15 & "'")

which comes from the following subroutine;
Code:
Private Sub Command4_Click()
Dim SearchTerm As String
Dim CustID As Integer
Dim BookingRefABC As String
SearchTerm = InputBox("Please enter a customers surname to search for...", "Search")
CustID = DLookup("CustomerID", "tblCustomers", "Surname='" & SearchTerm & "'")
Me.Text15 = CustID
BookingRefABC = DLookup("[Booking Reference]", "tblCampingBookings", "CustomerID='" & Me.Text15 & "'")
Me.Text17 = BookingRef
Me.frmCreditCardLookup.Requery
Me.frmCreditCardLookup.Visible = True
End Sub

Can anyone help me?
 
I've had this message caused by a few different things:

1) Is the customer ID definitely a string, not a number?
2) Is the variable BookingRefABC the same data type as [Booking Reference]?
3) Are the field and table names definitely correct?
4) Have you tried it with spaces between
Code:
CustomerID='
i.e.
Code:
CustomerID = '
 
You missed squair brackets in the statement and I think it would work if you changed this part
BookingRefABC = DLookup("[Booking Reference]", "tblCampingBookings", "CustomerID='" & Me.Text15 & "'")
to this
BookingRefABC = DLookup("[Booking Reference]", "tblCampingBookings", "[CustomerID] = '" & Me.Text15 & "'")
 

Users who are viewing this thread

Back
Top Bottom