2465 error, I think it's a syntax error

T

tstew

Hello,

The code below is giving me a 2465 error. I'm fairly new to VBA, but can
usually figure these things out after a bit of trial and error, but this one
has done me in so far. The code:

Private Sub Form_Current()

If IsNull([All NOTS].[Pic_Location] = True) Then
PicPic.Picture = CurrentProject.Path & "\Pics\NoPicYet.jpg"
End If

End Sub

I've checked field/table names over and over and tried a few other things.
BTW, I'm trying to get a picture in a form, if there is no pic file in the
Pic_Location field, display the NoPicYet.jpg file.

Any ideas?

Thanks
Mark
 
K

Klatuu

The error message is saying in can't find a field name referenced in your
code, but what I see is that you are checking for a Null condition where it
can never be null:

If IsNull([All NOTS].[Pic_Location] = True) Then

Will always return True or False, so the test will always be True. But that
will not cause the error.
 
T

tstew

Thank you!!

John_G via AccessMonster.com said:
Hi -

Instead of: If IsNull([All NOTS].[Pic_Location] = True), try

If IsNull([All NOTS].[Pic_Location]) then (the "= True" part should not
be there)

IsNull expects a field name or a variable, not a boolean expression, which is
what you currently have.

HTH

John





Hello,

The code below is giving me a 2465 error. I'm fairly new to VBA, but can
usually figure these things out after a bit of trial and error, but this one
has done me in so far. The code:

Private Sub Form_Current()

If IsNull([All NOTS].[Pic_Location] = True) Then
PicPic.Picture = CurrentProject.Path & "\Pics\NoPicYet.jpg"
End If

End Sub

I've checked field/table names over and over and tried a few other things.
BTW, I'm trying to get a picture in a form, if there is no pic file in the
Pic_Location field, display the NoPicYet.jpg file.

Any ideas?

Thanks
Mark

--
John Goddard
E-Mail: jrgoddard AT cyberus DOT ca



.
 
T

tstew

Thank you. It finally worked when I used "me.Pic_location" and left out the
"=True". Your help is much appreciated.

Klatuu said:
The error message is saying in can't find a field name referenced in your
code, but what I see is that you are checking for a Null condition where it
can never be null:

If IsNull([All NOTS].[Pic_Location] = True) Then

Will always return True or False, so the test will always be True. But that
will not cause the error.

tstew said:
Hello,

The code below is giving me a 2465 error. I'm fairly new to VBA, but can
usually figure these things out after a bit of trial and error, but this
one
has done me in so far. The code:

Private Sub Form_Current()

If IsNull([All NOTS].[Pic_Location] = True) Then
PicPic.Picture = CurrentProject.Path & "\Pics\NoPicYet.jpg"
End If

End Sub

I've checked field/table names over and over and tried a few other things.
BTW, I'm trying to get a picture in a form, if there is no pic file in the
Pic_Location field, display the NoPicYet.jpg file.

Any ideas?

Thanks
Mark


.
 

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