Run-time error '2001'

G

Guest

Hi,

I have a form where people can enter tape details and the value entered into
the text box is compared with a validations table to ensure that the correct
tape number is used. The tape number can be either numeric or alpha. The
code I am using is

Private Sub txtTape0_BeforeUpdate(Cancel As Integer)

If IsNull(DLookup("[Tape Validation]", "[validations]", "[Tape Validation] =
'" & Me.txtTape0 & "'")) Then
MsgBox "Please enter the correct tape number or container name"
Cancel = True ' wont let the user continue
End If

End Sub

I have 20 field that the user can update with tape numbers and each one has
the same code behind it (txttape0 - txttape19).

However, the db has started throwing up error '2001' you cancelled the
previous operation. I have tried this with square brackets and without
square brackets - but still the same. Can anyone help?

Thanks

Ann
 
G

Guest

It's very hard to know the couse for the error when we can't see the name of
the text boxes from and the dlookup you are running from each one of them.

Just to make sure, change a couple of things
Add a square brackets for the name of the text box, and use """ for the text
instead of "'"

Try
DLookup("[Tape Validation]", "[validations]", "[Tape Validation] = """ &
Me.[txtTape0] & """"))
 
G

Guest

Hi,

I have tried that bit of code and I am still getting the same error. The
text boxes are all called txtTape* (0-19) and I am using the same dlookup for
each text box in the before update property.
--
Ann Hodgetts


Ofer Cohen said:
It's very hard to know the couse for the error when we can't see the name of
the text boxes from and the dlookup you are running from each one of them.

Just to make sure, change a couple of things
Add a square brackets for the name of the text box, and use """ for the text
instead of "'"

Try
DLookup("[Tape Validation]", "[validations]", "[Tape Validation] = """ &
Me.[txtTape0] & """"))
--
Good Luck
BS"D


AMHodgetts said:
Hi,

I have a form where people can enter tape details and the value entered into
the text box is compared with a validations table to ensure that the correct
tape number is used. The tape number can be either numeric or alpha. The
code I am using is

Private Sub txtTape0_BeforeUpdate(Cancel As Integer)

If IsNull(DLookup("[Tape Validation]", "[validations]", "[Tape Validation] =
'" & Me.txtTape0 & "'")) Then
MsgBox "Please enter the correct tape number or container name"
Cancel = True ' wont let the user continue
End If

End Sub

I have 20 field that the user can update with tape numbers and each one has
the same code behind it (txttape0 - txttape19).

However, the db has started throwing up error '2001' you cancelled the
previous operation. I have tried this with square brackets and without
square brackets - but still the same. Can anyone help?

Thanks

Ann
 
G

Guest

Do you get the error in all text boxes or just some of them?

If it's happen only in a certain text box, check if the name is written
properly.
Post the code of the before update event of one of the text boxes where the
error happen (please include the sub name)

Sub SubName()
' code
End Sub

--
Good Luck
BS"D


AMHodgetts said:
Hi,

I have tried that bit of code and I am still getting the same error. The
text boxes are all called txtTape* (0-19) and I am using the same dlookup for
each text box in the before update property.
--
Ann Hodgetts


Ofer Cohen said:
It's very hard to know the couse for the error when we can't see the name of
the text boxes from and the dlookup you are running from each one of them.

Just to make sure, change a couple of things
Add a square brackets for the name of the text box, and use """ for the text
instead of "'"

Try
DLookup("[Tape Validation]", "[validations]", "[Tape Validation] = """ &
Me.[txtTape0] & """"))
--
Good Luck
BS"D


AMHodgetts said:
Hi,

I have a form where people can enter tape details and the value entered into
the text box is compared with a validations table to ensure that the correct
tape number is used. The tape number can be either numeric or alpha. The
code I am using is

Private Sub txtTape0_BeforeUpdate(Cancel As Integer)

If IsNull(DLookup("[Tape Validation]", "[validations]", "[Tape Validation] =
'" & Me.txtTape0 & "'")) Then
MsgBox "Please enter the correct tape number or container name"
Cancel = True ' wont let the user continue
End If

End Sub

I have 20 field that the user can update with tape numbers and each one has
the same code behind it (txttape0 - txttape19).

However, the db has started throwing up error '2001' you cancelled the
previous operation. I have tried this with square brackets and without
square brackets - but still the same. Can anyone help?

Thanks

Ann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top