Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking an Image in Access reports using a combo box field 1

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
GB
Hi, [smile]

Thank you for all the help I have received in the past [bigsmile]

Please could I have help on the following:

I have a Report: ChsPltRef; that has a field PLATREF that the .jpg images are named after; in the folder: G:\LIPHOTOS\

So I want to have a dynamic image in the Report: ChsPltRef; according to the Field: PLATEREF found in the Form: ChsPltRef, combo box: Combo0, generated from the Query: NFrmCRefAs.

The Report: ChsPltRef is generated with the following forms and Queries:
Forms: ChsPltRef: Has 2 combo boxes: Combo0 this has a list of fields generated from the Query: NFrmCRefAs; using the field name: PLATEREF.

Combo1 field (REFVAL)is generated from the query PlateChs, it is filtered by Combo0, so only the instances of REFVAL that appear; are those that are related/linked to PLATEREF.

Queries: RefChs: Generates the report according to combo1 in the Form: ChsPltRef.
NFrmCRefAs: generates the field PLATEREF for combo0
PlateChs: It is filtered by Combo0, so only the instances of REFVAL that appear are those that are related/linked to PLATEREF

The Report has an image/blank image;
I want to link to a folder containing images (jpg's) that have the same file name as the reference number(PLATEREF)(Combo0);
I would like to find out how to link the correct picture in the folder to the field name(Combo0(PLATEREF) the picture is named after.

I have the following code in the report on the image:
Code:
G:\LIPHOTOS\[FORMS]![ChsPltRef].[combo1] &".jpg"
It comes up with the following error:
Microsoft Access can't open the file:G:\LIPHOTOS\[FORMS]![ChsPltRef].[combo1] &".jpg"
Am I linking the picture in the incorrect way?
I have clicked on the image icon and inserted a image onto the report.
Should I put a bound/unbound object Frame rather than an image?
How would I go about linking these pictures named according to the field name PLATEREF Combo0)

Any help would really be appreciated [smile]
I am really stuck here...[banghead]
Please help [sadeyes]
Kind regards
Triacona
 
dim path as string
path = "G:\LIPHOTOS\" & [FORMS]![ChsPltRef].[combo1] & ".jpg"
now open the path
 
Hi MajP,

Thank you very much for your reply.
Where would I insert this code?
The code I have is currently in the image properties, in Picture: G:\LIPHOTOS\[FORMS]![ChsPltRef].[combo1] &".jpg"
Picture type: linked
There another way I should be working with the image box; should I be using a bound/unbound object frame?

Thank you again [smile]

kind regards
Triacona
 
OK now I understand. I thought you where doing this in code, but you are doing it in the property. That is why it does not work because the property is assumed to be named
" G:\LIPHOTOS\[FORMS]![ChsPltRef].[combo1]"
it can not resolve [FORMS]![ChsPltRef].[combo1]

Private Sub Report_Load()
Dim path As String
path = "G:\LIPHOTOS\" & [Forms]![ChsPltRef].[combo1] & ".jpg"
Me.Image2.Picture = strPath
End Sub
 
Hi MajP,

Thank you for all your help [thumbsup]

I'm assuming the code you gave me in supposed to be used for the cmd button to preview the report?

For that senario I have:
Code:
Private Sub GenAcRepCrd_Click()
On Error GoTo Err_GenAcRepCrd_Click

    Dim stDocName As String

    stDocName = "ChsPltRef"
    DoCmd.OpenReport stDocName, acPreview
    path = "G:\LIPHOTOS\" & [Forms]![ChsPltRef].[Combo1] & ".jpg"
    Me.Image2.Picture = strPath
    

Exit_GenAcRepCrd_Click:
    Exit Sub

Err_GenAcRepCrd_Click:
    MsgBox Err.Description
    Resume Exit_GenAcRepCrd_Click
    
End Sub
I have named the image box in the report image2
I get a compile error:
Method or data member not found

Am I on completely the wrong track?

The report structure is as follows:
It has 2 images 1 linked and the same throughout, and another image frame with no image (meant to be dynamic) as of yet.

And then a list of fields below this; one of them including PLATEREF.

Where is this code meant to be implemented?

Thank you ever so much[smile]
Kind regards
Triacona
 
No I used it in the reports on load event. When the report opens it pulls the image path from the open form. The forms cmd button just opens the report.
 
Hi MajP,

Thank you very very much for you help [2thumbsup]
I modified the code as such:
Code:
Private Sub Report_Activate()

 Dim path As String
  
    path = "G:\LIPHOTOS\" & [Forms]![ChsPltRef].[Combo0] & ".jpg"
    Me.Image2.Picture = path

End Sub
Thank you again, it works and pulls through the images, beautifully.[bigsmile]
Kind regards
Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top