I have a messy solution that doesn't require you to load an ActiveX custom control. Why not create a form with with the appropriate colors and corresponding labels and use it as a subform?
Here's how it works:
1. Create a form called colordropdown.
2. Create a label for each color choice.
3. Create a rectangle object filled with color corresponding to its label.
4. Create a text box called colorchoice and make it small (not hidden).
5. Set the onclick event for each of the labels and rectangles to pass the appropriate value to the colorchoice textbox.
Option Compare Database
Option Explicit
Dim MyName As String
Sub BlackLabel_Click()
myname = "Black"
colorchoice.value = myname
End Sub
6. Set the the following Form Properties:
Default View: Single Form
Views: Allowed Form
Scroll Bars: Vertical Only
Record Selectors: No
Navigation Buttons: No
Dividing Lines: No
Auto Resize: No
Auto Center: No
Border Style: Dialog
Min Max Buttons: None
6. Place the colordropdown form in your main form as a subform.
7. Set the Visible property of the subform to False.
8. On your Parent form, create a Textbox called ColorResult.
9. Set its default value to the appropriate value (auto for example).
10. Set the On Exit event of the subform to pass the value of ColorChoice to ColorResult.
11. Set the On Update event of the ColorResult to move the focus to ColorResult and hide the subform.
12. Draw a Rectangle on your Parent form next to the ColorResult Textbox and embed a down arrow paint object.
13. Set the On Click event of the rectangle to show/hide the subform.
I know that this is a great big mess, but I got it to work for me at work. I needed to be able to do the same thing, but system admin forbade me to download any custom activex controls so I had to create my own. Hopefully, someone can propose a better one than this for you.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.