Combo box Value Must Show an object: How To

I mean, create another field in the HARD table to store the path of the image. You'll have to change the control source of the combo box though. I would recommend creating a query (read the help file)

Alternatively, if you're only using the HARD table for this one combo box it might be an idea to just enter the values you want (server and so on) into the combo box yourself, rather than basing it on a table (read the help file again)
 
I created another field in the hard table and then what .....

what do you mean "store the path of the image" I have an image on a form... and what path should it be?
 
Basically what we want to do is to store whatever you'd enter in the "Picture" property of the image object (cheers VBA) - so the path of the image. For example "C:\Documents and Settings\James\Pictures\Pic001.jpg"

Do you see where we're going with this?
 
I did everything as you explained, but Compilation says: Method or data member not found"
 
Something's gone wrong then - I've just done it on your test DB and it works fine.

Step 1: Add a column into the HARD table after the HARDWARE field and add the path of the image you want to see next to each entry (SERVER, etc.). i.e. c:\pictures\pic1.jpg

Step 2: Ensure your combo box is looking at the HARD table. In its properties increase the column count to 2. Set the column widths to "2cm;0cm". Set the bound column to 1.

Step 3: In the AfterUpdate event of the combo box, put this:
Code:
Private Sub MODELI_AfterUpdate()
ok.Visible = True
ok.Picture = MODELI.Column(1)
End Sub
Step 4: Go to form view. As you select values from the combo box you'll see the picture changing.
 
You're most likely using the wrong control.

Not an OLEUnbound object, you need an Image control.
 
It's the right control, I just did it and it works OK.... Here, have a look at this. Not sure if you're aware of the MsgBox function but you can use that instead of having a form popping up just to say "Error"

PS In order for this to work you'll have to change the file paths in the HARD table to a valid picture on your drive.
 

Attachments

If i do this, what will be with the images? will they embedded to a database or i must carry the images with the Access file?
 
It depends on what you want to do with the database once you've finished with it. If you're copying it several times to different machines (not recommended) you can specify LOCALHOST as part of the path to the image (google it) - I think so, anyway
 
I'll Read it, but i think it would be a better variant to do this with:

Select Case Me.Hardware
Case "Server"

"But here i couldn't figured out what to write. Idea is: If Case "Server" is true then imagename.visible=true

Case Else
DoCmd.OpenForm "ERROR", acNormal
End Select
 
The select case I was talking about was for opening the detail form when you click on the image. There's no point in having a select case statement in the combo box code...

The way we're doing it is best in my opinion - if you start embedding files in your database it'll get really big, really quick.
 
Ok....
Thank you James at home I'll do as you explained ...... I really don't wont that my database increased by embedded image files... I'll put my Access file in a folder as a project with data and image files.
 
Hello James It worked .... Thank you Very Much
 

Users who are viewing this thread

Back
Top Bottom