Pictures in report

V

Veli Izzet

Hi,

I need to put the picture of the item on the report. I have a piece of
code that I can do it on the current event of a form, but I could not
get that code to work with the report.

Needless to say, one field keeps the path to the pictures (in jpg), and
pictures are not in the database.

The code for the form is:

Private Sub Form_Current()
On Error Resume Next
If Len(Dir(CurrentProject.Path & "\slides\" & Me![KOD] & ".jpg")) Then
Me![ImagePic].Picture = CurrentProject.Path & "\slides\" & Me![KOD]
& ".jpg"
Else
Me![ImagePic].Picture = ""
End If
End Sub

How do I modify the code?

TIA
 
A

Arvin Meyer

If Len(Dir(CurrentProject.Path & "\slides\" & Me![KOD] & ".jpg")) Then

Len(gth) is what? You need something like:

If Len(Whatever) >0 Then

In other words the file length needs to be greater than zero to use the
first code branch, Else use the second code branch.

If Len(Dir(CurrentProject.Path & "\slides\" & Me![KOD] & ".jpg")) >0 Then

Make sense now?
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
D

Douglas J. Steele

While I agree that it's better coding practice to include the > 0,
theoretically shouldn't the code work equally well without it, since a
non-zero value will be treated as True, and a length of 0 will be treated as
false?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Arvin Meyer said:
If Len(Dir(CurrentProject.Path & "\slides\" & Me![KOD] & ".jpg")) Then

Len(gth) is what? You need something like:

If Len(Whatever) >0 Then

In other words the file length needs to be greater than zero to use the
first code branch, Else use the second code branch.

If Len(Dir(CurrentProject.Path & "\slides\" & Me![KOD] & ".jpg")) >0 Then

Make sense now?
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access

Veli Izzet said:
Hi,

I need to put the picture of the item on the report. I have a piece of
code that I can do it on the current event of a form, but I could not
get that code to work with the report.

Needless to say, one field keeps the path to the pictures (in jpg), and
pictures are not in the database.

The code for the form is:

Private Sub Form_Current()
On Error Resume Next
If Len(Dir(CurrentProject.Path & "\slides\" & Me![KOD] & ".jpg")) Then
Me![ImagePic].Picture = CurrentProject.Path & "\slides\" & Me![KOD]
& ".jpg"
Else
Me![ImagePic].Picture = ""
End If
End Sub

How do I modify the code?

TIA
 
V

Veli Izzet

BTW,

The code works on the Form, where do I put it on the report? On the form
the code is "on current"?
 

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