ACCESS ERROR 2465???????

G

Guest

Hello!!!!
I would like to find out how to fix this error that shows up on the "Before
Update to prevent duplicate entries". I am presently
using the following code:
Private Sub txtMy Field_BeforeUpdate(Cancel as Integer)
If Not IsNull(DLookUp("[MyFIELD]",
, _
"[MyFIELD] = '" & Me!txtMy Field& "'") Then
MsgBox "This MyFIeldhas already been entered", vbOKOnly
Cancel = True
End If
End Sub
Specifically, the error showed reads like this:"Run- Time error 2465
Microsoft access can't find the field 'l' referred to in your expression"
I have tried everything I know but obviously My understanding of this is
quite limited....
 
J

John Vinson

I would like to find out how to fix this error that shows up on the "Before
Update to prevent duplicate entries". I am presently
using the following code:
Private Sub txtMy Field_BeforeUpdate(Cancel as Integer)
If Not IsNull(DLookUp("[MyFIELD]",
, _
"[MyFIELD] = '" & Me!txtMy Field& "'") Then
MsgBox "This MyFIeldhas already been entered", vbOKOnly
Cancel = True
End If
End Sub
Specifically, the error showed reads like this:"Run- Time error 2465
Microsoft access can't find the field 'l' referred to in your expression"


If that is actually a copy and paste of the Sub you have MANY MANY
errors. As posted it would not even compile (there's a blank between
txtMy and Field in the Sub name) so I'm guessing it isn't.

My *suspicion* is that in your actual code you have the actual name of
your table *in square brackets* as the second argument to DLookUp. The
brackets aren't a problem but the second argument needs to be a
String, not an object.

Try changing the
to "
" (using your actual table name of
course; and (if your control name has a blank in it, which is a Bad
Idea) change

Me!txtMy Field&

to

Me![txtMy Field] &


John W. Vinson[MVP]
 

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

Similar Threads


Top