No "On Current" in Report

  • Thread starter Thread starter GKuenning
  • Start date Start date
G

GKuenning

Guest
Couldn't find the answer to this question in the search...

I'm trying to use this code:

If Not Me!PHOTO_LINK = "" Or Not IsNull(Me!PHOTO_LINK) Then
Me!Image62.Picture = Me!PHOTO_LINK
Else
Me!Image62.Picture = ""
End If

in a report, so that my linked photo is visible for each record. The help tells you to put it under "On Current" just like a form, but there is no "On Current" in my report. I tried putting the code under "On Page" but it linked the wrong picture to each record. Please Help!

Thanks.
 
GKuenning said:
.. but there is no "On Current" in my report.

Perhaps try putting it on the On Activate. Otherwise, with VBA you can create an On Current event.. but I've never seen it done to a report (probably because the report doesn't have an OnCurrent).

The order in which events trigger for a report are: Open -> Load -> Resize -> Activate -> Current

Something to chew on unless it fixes it. I'm sure someone will correct me. :p
 
Tried that, didn't work...

I tried it in "On Activate" but it told me that it couldn't find the field "PHOTO_LINK", and that's the name of the field the photo link is saved in. Any more ideas anyone?
 
Did you try to put the code in the On (section)Format event for the report?

With your report in design view, click on the section of the report where the photo appears. Then use the On Format event.

HTH,

Doug
 
Last edited:
No luck yet.

I get the same error again. "Microsoft Access can't find the field 'PHOTO_LINK' refered to in your expression." Is there somewhere else that I need to refer to the PHOTO_LINK field in order for it to be recognized?
 
Yes, that's what I just tried and it gave me that error message. Do I have something wrong with my code from the first post?
 
I would suspect that 'PHOTO_LINK' is not a valid field name, however if it is then most here would re-name the 'PHOTO_LINK' control to something else say txtLink and then use Me.txtLink to refer to it in vba
 
Tried that

OK, I renamed my field to txtLink, and entered this code under Detail>On Format

If Not Me!txtLink = "" Or Not IsNull(Me!txtLink) Then
Me!Image62.Picture = Me!txtLink
Else
Me!Image62.Picture = ""
End If

I got the same error message as before, "Run-time error '2465: Microsoft Access can't find the field 'txtLink' referred to in your expression.

Thanks for trying. Any other thoughts?
 
Another Thought

When I enter this code into the "On Format" field, I don't receive an error message, but it also doesn't place my photo either.

On Error Resume Next

Me!Image62.Picture = Me!txtLink

Someone out there has to have linked photos to a report like this, it doesn't seem like it should be this difficult. :)
 
Debug

When it gives me that error, I have the option to "debug", what does that do?
 
GKuenning said:
When it gives me that error, I have the option to "debug", what does that do?

If you click on the debug button it will display the code and highlight the line where the error occurs.

Post the code here and state the line which is causing the problem - you should get a more reasoned answer to your problem.
 
DeBug Conclusion

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Not Me!txtLink = "" Or Not IsNull(Me!txtLink) Then
Me!Image62.Picture = Me!txtLink
Else
Me!Image62.Picture = ""
End If

End Sub

It's highlighting the first line when I choose Debug:

"If Not Me!txtLink = "" Or Not IsNull(Me!txtLink) Then"

Any thoughts?
 
OK, so I now used this for my code replacing all "bangs" with "dots":

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Not Me.txtLink = "" Or Not IsNull(Me.txtLink) Then
Me.Image62.Picture = Me.txtLink
Else
Me.Image62.Picture = ""
End If

End Sub

I still get the same error message: "Run-time error '2465: Microsoft Access can't find the field 'txtLink' referred to in your expression." and the debug still points to the first line.

"If Not Me.txtLink = "" Or Not IsNull(Me.txtLink) Then"

How do you guys feel about File Maker Pro? :rolleyes: Just Kidding, I haven't gone over the edge just yet!
 
Woo Hoo!

Rich, you're the man! Thanks for sticking with me!

The whole problem was that I didn't have the txtLink field in the report at all. I didn't realize I had to have a seperate field on top of the image field. When you asked me what section I had THOSE fields in, it hit me. So, this code ended up working:

If Not Me!txtLink = "" Or Not IsNull(Me!txtLink) Then
Me!Image62.Picture = Me!txtLink
Else
Me!Image62.Picture = ""
End If

Thanks again for the help, I really appreciate it.
 

Users who are viewing this thread

Back
Top Bottom