Display attachment image in form based on combo box selection (1 Viewer)

Maarten

Registered User.
Local time
Today, 23:46
Joined
May 13, 2013
Messages
12
Hello guru's,

I was wondering if you could help this n00b. I have been Googling and reading this and other fora, but found no solution to my problem.
I'm working on a wine database (for ages now...). I'm currently struggling getting the following to work. I have a form in which one can select the name and vintage of a wine using a combo box, after which also a picture will be shown of that wine. I have the pictures as attachments in a table. One can then press a button to close this form and go to another form in which one can edit all the details of the selected wine. Problem: I can't get the picture to show.

I have a reasonably simple form with a combo box, a text box, a button and an attachment field in which a picture should show.
I made a query to select the id, name and vintage from the wine table. I couldn't select the attachment field for the pic in the wizard, so I added that myself in the Design View. The Query for the combo box now reads:
Code:
SELECT Wijn.Id, Wijn.Naam, Wijn.Vintage, Wijn.Plaatje FROM Wijn ORDER BY Wijn.[Naam], Wijn.[Vintage];
(translation: Naam = name | Plaatje = picture)
It neatly shows name and vintage in the drop down list. Once selected it only shows the name of the wine in the combo box and I use VBA to fill the Text Box with the vintage of the selected wine (if there's a better way, please let me know. This feels like a silly solution, but it works, anyway...). The VBA I use is:
Code:
Private Sub cmbNaamWijn_Change()
Me.txtVintage.Value = Me.cmbNaamWijn.Column(2)
End Sub
All works fine. Also when I pres the button, the wine I selected opens up and can be editted and the select form nicely closes. The only problem is the fact that I cannot get the picture to show!

I inserted an attachment field with the name: attImage.
In the VBA code I added the line:
Code:
Me.attImage.Picture = Me.cmbNaamWijn.Column(3)
Doesn't work. With debugging I do see it gets the correct value form the table. I get an error message stating "Method or data member not found", so Picture is not available for the attachment object I guess.
If I look at what is available, I can't select anything useful. So my next try was adding an image control with the name: ImageWine and the VBA code in the On Change property
Code:
Me.ImageWine.Picture = Me.cmbNaamWijn.Column(3)
results in the following: Run-time error '2220'. Microsoft Access can't open the file '[FilenamePicture]'. Logical in a way I guess, since there's no path in there. I also tried the Bound Object Frame, but that resulted in the same problem as the attachment try described above.
So can anyone please help me, I ran out of ideas?
 

Maarten

Registered User.
Local time
Today, 23:46
Joined
May 13, 2013
Messages
12
Soooo... No responses, does this mean it's not possible?
 

Users who are viewing this thread

Top Bottom