Linking pictures to a combox (1 Viewer)

lyndonrobertson

Registered User.
Local time
Today, 14:36
Joined
Aug 30, 2012
Messages
20
I have got a database together where I have a selection of 15 cars. I have it programmed off a table at the moment where one com-box displays the manufacturer you select the manufacturer and it brings up 1 or 2 models.

my next aim is when you pick the model i want a picture to come up of the car next to the com-box

I have inserted a image-box and have tried to program it with several different bits of vba code off the net but i cant get it to work :(

I do have the links in text format in the same table as the cars table.

the code I have in there at the moment which doesn't work is

Private Sub cmdExplore_Click()
On Error GoTo Err_cmdExplore_Click

Dim stAppName As String

stAppName = "V:\ur-t-52\Product Integration & Methods\PI_folders\M. James\Benchmarking\Benchmarking Database\Photos"
Call Shell(stAppName, 1)

Exit_cmdExplore_Click:
Exit Sub

Err_cmdExplore_Click:
MsgBox Err.Description
Resume Exit_cmdExplore_Click

End Sub

Please be aware I am a newbie at this so be patient :)

thank you in advance
 

Trevor G

Registered User.
Local time
Today, 22:36
Joined
Oct 1, 2009
Messages
2,341
Welcome to the Forum,

create a table with the details for the images and then the manufacture and model, assigning each with a number and then you can use that source for the combo, and use the after udpate event to trigger showing the image into the image field on the form.

The combo would need to reduce the column widths to zero for the fields you don't want to show.
 

lyndonrobertson

Registered User.
Local time
Today, 14:36
Joined
Aug 30, 2012
Messages
20
I have all the data in one table already assigned with a ID

but how would I go about writing code or setting it up so when the model is selected a picture is displayed

please see image attached
 

Attachments

  • combox.jpg
    combox.jpg
    95.7 KB · Views: 91

John Big Booty

AWF VIP
Local time
Tomorrow, 07:36
Joined
Aug 29, 2005
Messages
8,262
Perhaps this sample will help you.

Ensure that you copy the DB and image folder (called flags) to the same location.
 

Attachments

  • Flags.zip
    354.6 KB · Views: 96

lyndonrobertson

Registered User.
Local time
Today, 14:36
Joined
Aug 30, 2012
Messages
20
tried using your database but had a bit of toruble getting it working it's there now¬

one problem though it isnt quite what im looking to do with mine
 

Simon_MT

Registered User.
Local time
Today, 22:36
Joined
Feb 26, 2007
Messages
2,177
So It is not until you get down to the Model that the specific ID is determined.

So AfterUpdate on the ModelID you can find the Image. So if the Image file Name equals the ModelID then you can associate the Imafge to the Model through its ID.

First in your Query behind your form

ImageFile = [ModelID] & ".jpg"

Code:
Function GetPictureDir() As String
    GetPictureDir = "V:\ur-t-52\Product Integration & Methods\PI_folders\M. James\Benchmarking\Benchmarking Database\Photos"
End Function
Code:
Function GetPicturePath()
    With CodeContextObject
        GetPicturePath = GetPictureDir & .[ImageFile]
    End With
End Function
Code:
Function GetPicture()
    With CodeContextObject
            .[ImageControl].Picture = GetPicturePath
    End With
End Function

Simon
 

lyndonrobertson

Registered User.
Local time
Today, 14:36
Joined
Aug 30, 2012
Messages
20
when you say in the query behind the form

ImageFile = [ModelID] & ".jpg"

where do i enter this?

I cant see anywhere i can enter any sort of coding?
 

Simon_MT

Registered User.
Local time
Today, 22:36
Joined
Feb 26, 2007
Messages
2,177
Are you using a query?

If not create a control on your Car Select form called ImageFile

Control Source = [ModelID] & ".jpg"

Simon
 

lyndonrobertson

Registered User.
Local time
Today, 14:36
Joined
Aug 30, 2012
Messages
20
I have created a control box which showss the links but does not open the file
 

Simon_MT

Registered User.
Local time
Today, 22:36
Joined
Feb 26, 2007
Messages
2,177
Using my example, although you can call it what you like, If this is called Image then try

Create the Functions

Event AfterUpdate on your Combi for ModelID

Call GetPicture

We will get there. It is not difficult but a bit fiddly.

Simon
 

lyndonrobertson

Registered User.
Local time
Today, 14:36
Joined
Aug 30, 2012
Messages
20
simon_gt

tried following your method and been greeting with this message.

i dont know if this emans it cant find the direcetory or there is something wrong with the imagefile wording
 

Attachments

  • error.jpg
    error.jpg
    85.2 KB · Views: 79

Simon_MT

Registered User.
Local time
Today, 22:36
Joined
Feb 26, 2007
Messages
2,177
Please post a copy of the your database I will have a look, don't bother with the images I have plenty.

Simon
 

Simon_MT

Registered User.
Local time
Today, 22:36
Joined
Feb 26, 2007
Messages
2,177
Lyndon

I have already sent you a PM.

Simon
 

Users who are viewing this thread

Top Bottom