Run Time Error 2001 You Canceled The previous operation

Johnkl

New member
Local time
Today, 02:49
Joined
Aug 29, 2002
Messages
28
Good morning

I use the following code to update a field

Private Sub Supplier_AfterUpdate()
Dim strFilter As String

strFilter = "SupplierID=" & Me!Supplier
Me!Venue = DLookup("VenueName", "tblVenues", strFilter)
End Sub

But it come back woth an error "Run Time Error 2001 You Canceled The Previouw Operation"

The Data Type Of Venue and Venue Name is Text

Can anyone help please??

Regards
John
 
If SupplierID is a text field, you will need the following:
strFilter = "SupplierID= '" & Me!Supplier & "'"
 
Run Time Error 2001 You Canceled the previous operation

Nop SupplierID and Supplier is numeric fields

Supplier is a combo box

Any other suggestions??

Thanx
 
How about adding the following code to see what you are asking DLookup() to look for?
Code:
strFilter = "SupplierID=" & Me!Supplier
[COLOR="Red"]MsgBox "strFilter = [" & strFilter & "]"[/COLOR]
Me!Venue = DLookup("VenueName", "tblVenues", strFilter)
 
The field in the tblVenues table is named Supplier and not SupplierID.
strFilter = "[Supplier] =" & Me!Supplier
This is one of the main reasons why it is recommended that ForeignKeys be named the same name as the key name in the table where it is a Primarykey.
 
Last edited:
Rural Guy good morning

Thanks alot that was the case
 
This prior post was a tremendous help.

I had the following code which didn't work on the current form (but worked on another for reasons unknown):
Code:
Me!TYPE5SUBFRM.Form.Filter = "agency=""" & Me.Combo2.Column(0) & """"
Corrected to, which works!
Code:
Me!TYPE5SUBFRM.Form.Filter = "agency="& Me.Combo2.Column(0)

Thanks RuralGuy
 
This prior post was a tremendous help.

I had the following code which didn't work on the current form (but worked on another for reasons unknown):
Code:
Me!TYPE5SUBFRM.Form.Filter = "agency=""" & Me.Combo2.Column(0) & """"
Corrected to, which works!
Code:
Me!TYPE5SUBFRM.Form.Filter = "agency="& Me.Combo2.Column(0)

Thanks RuralGuy
Probably because agency is a numerical value.
 
You are correct, it is a number. Column(0) contains the agency idnumber and Column(1) contains the name of the agency form a table AGENCYLIST.
 
The first example you posted is the way you would code it if agency were a string or text value.
 
I keep tripping over these nuances. Being able to search the forum for these solutions has been a life saver. Live and learn. Thanks.
 

Users who are viewing this thread

Back
Top Bottom