Displaying OLE object on a form

kermit5

Registered User.
Local time
Today, 02:03
Joined
Nov 2, 2001
Messages
122
I would like to display an image on a form that corresponds to an user made selection.

The jist of my program is thus:
The user is defining the specifications for a lock. One of the fields required is the style of lever that they want. I have that selection set up in a combo box populated by a query that displays the available styles for a specified manufacturer. I would like to display on my form an image of the lever style selected upon selection or even better would be to show the image when the style is in focus. That is to say, as the user points to the trim style with the mouse or by scrolling down the list, the lever style image would appear.

How do I do this?
 
Kermit5

You probably should make a table for your lever pics. (ole objects)
Store the pics in the table.

When the combo box selects a certain lever, you can use code or a macro to fill your picture box with the specific pic.

eg.
in the 'on change' event of the combo box

Private Sub YourComboBox_OnChange(Cancel As Integer)

If YourComboBox = 1 Then
PictureBox = Pic1
EndIf

If YourComboBox = 2Then
PictureBox = Pic2
EndIf


End Sub

Now, I didn't try this, but it should give you a start.
Good luck
Tom
 
OLE object communication error

I added to my form a bound OLE object frame and linked it to the image of the lever style via a query. I now have two questions:
1. when the form loads, I get the following error:
Microsoft Access can't read the OLE object because communication was interrupted.
My Access software is installed on my local machine. What is causing this error?

2. How do I ensure that the image is updated to the new image when the value in cmbLockTrimStyle is changed (what do I put in the OnChange or AfterUpdate events)?
 
Kermit5

Try this.

1. Your 'Picture table' should have three fields.
PictureID (autonumber)
Style (text)
Picture (ole)

2. Now back to your 'Bound Object frame' properties
Control Source
=DLookUp("[Picture]","Picture table","[Style]=[cmbLockTrimStyle]")

3. In your 'cmbLockTrimStyle' event properties
'On Change' select [Event Procedure] go to vb window ...
enter this code

Private Sub 'cmbLockTrimStyle_Change()
Me!Bound Object frame name .Requery
End Sub


As you select a style, your picture should change.

Tom
 
Last edited:
Marvelous!

Thank you. That is what I was looking for.
 

Users who are viewing this thread

Back
Top Bottom