Image display as you move through a drop down list (1 Viewer)

T. McConnell

Registered User.
Local time
Today, 07:15
Joined
Jun 21, 2019
Messages
63
Greetings all,
I am looking to see if this is even a possibility or not. I have a drop down list for different products. I also have images on a products form where parts are entered into the database. Is there a way that when you open the drop down to select a product, as you hover over the different selections you can display the associated image to the selection. More or less looking for a way to show the image of the part being selected to ensure proper part is chosen. I am even open to if can't do it this way, then maybe when at least selecting the part it opens up a form (popup subform if you will) that goes directly to that part by part ID. Any suggestions would be greatly appreciated.
Thanks!
 

Micron

AWF VIP
Local time
Today, 07:15
Joined
Oct 20, 2018
Messages
3,476
AFAIK, there is no method for determining what list item is highlighted in a combo box, so work arounds are required. I have never done what you want, but I suspect the approach is to:
- use a MouseMove event for the combo. However, you don't want this to fire unless the list is dropped down, and there is no "dropped down" property either. To know the state of the list, there is API code here for this, which also contains a link to another site that uses a different method (but I had to look for it) so this might be the file in question (see Combo Current Row). However, I believe it is Access 97 which may not open with your version (you didn't say what that is).

- once you know if the list is dropped down, the mousemove should be able to return the position of the cursor, but you have to then calculate the row based on row height. If the mousemove event returns a value of 27 relative to the combo position and the rows are 13.5, you are on row 2. Then you can use that to determine the index, which gives you the ability to retrieve any value from a list column. Obviously some math would be involved.

Maybe not worth the effort? Perhaps some other design element would make this easier, such as navigating through subform (datasheet or continuous) form records. A single image control could display the appropriate image as the user mouses/keys down the list. Or someone else may have a method that is less convoluted than what I was able to find.

EDIT - just realized that you would also have to make sure your list rows property would always be conducive to the combo position. You would not want to have the situation where you changed that property setting or moved the combo and the list that descended all of a sudden rose instead (opened above instead of below the combo).
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 11:15
Joined
Jan 14, 2017
Messages
18,186
Do you have room for a listbox instead of a combo?

If so, I have exactly what you need as part of my example app Accurately Move Forms and Controls.
See form 5 in the example where the form image is updated as you move over each item in the listbox. It works perfectly no matter what font size or style is used. The accompanying article explains the code in detail.

Hope that helps
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:15
Joined
May 7, 2009
Messages
19,169
there is also an ActiveX ImageCombobox control available on Access.
 

Attachments

  • ImageCombobox.zip
    41.9 KB · Views: 90

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:15
Joined
May 7, 2009
Messages
19,169
just a couple of warning before using mr.colin's listbox.
make sure the listbox is Unbound.
you'll face a lot of trouble if it is Bound because it will update the bound field.
also it will only work when the full list is displayed.
so if your listbox is small, only showing less items from the list, it will show wrong picture, or will not select at all the listitem, when you scroll through the listbox.
 

isladogs

MVP / VIP
Local time
Today, 11:15
Joined
Jan 14, 2017
Messages
18,186
@Arnelgp

just a couple of warning before using mr.colin's listbox.
make sure the listbox is Unbound.
you'll face a lot of trouble if it is Bound because it will update the bound field.

That comment applies to any listbox or combo box.

also it will only work when the full list is displayed.
so if your listbox is small, only showing less items from the list, it will show wrong picture, or will not select at all the listitem, when you scroll through the listbox.

True. That was why I asked if the OP had room for a listbox

As always, many thanks for trying out one of my applications.
However I'm still waiting for the day when you say anything positive about any of my work...
Too often you incorrectly say something doesn't work when it does.
When I respond or ask for clarification you do not reply.
 

T. McConnell

Registered User.
Local time
Today, 07:15
Joined
Jun 21, 2019
Messages
63
I appreciate the info. With this current setup, I don't have room for a full list box.
What I decided to try and so far it seems to work was I created a Query to display the picture from the Inventory table, and created a form from that query. So basically all it is is a small form (popup) that displays the image only. Then on the before update event on the drop down, I place code to display the appropriate picture based on the dropdown selection. It will change when a different part is selected, this works for the client as at least they can see the part before the actually submit an order.

So for anyone who may want to do something similar (and yes I am sure it can be tweaked and made more functional I am sure) Here is what I have done.
I have a table called Inventory, within the table for sake of this example I have ProductID, (AutoNum) Product, (Text) and Picture. (Attachment)

Query is based off these 3 fields from the table. Then on my form, (called PartPictures) which is tied to that Query I added those 3 to the form, but made ProductID and Product not visible.

On the drop down of my subform calling the picture I used this code in the before update event.
Code:
DoCmd.OpenForm "PartPictures", acNormal, , "[ProductID] = " & Me.ProductID

These seems to work for what the client is wanting. If it helps anyone great, if not that is ok too :)
 

isladogs

MVP / VIP
Local time
Today, 11:15
Joined
Jan 14, 2017
Messages
18,186
Nice and simple.
Glad you have a solution for your needs
 

Users who are viewing this thread

Top Bottom