[RESOLVED] ComboBox manipulation
Hello,
In MS Access 2003, i want to do two things with my ComboBox controls:
First - make it read only:
On several combo boxes, i already loaded a list of selectable items.
I want the user to choose from them, but not to be able to enter any text into the text box area of the combo box (like the vb6 drop down style).
Second - catch an event when the user clicks on the drop-down arrow:
On a few of my combo boxes, i enabled an action on the Mouse_Down event.
This action shows a date picker which is called "ocxCalander".
But that's not good for me, because I don't want the date picker to show when the user clicks on the text box area. That's because i want the user to still be able to type a date.
Just when the user clicks on the down arrow, i want the date picker to show.
Thanks ahead and regards,
Re: ComboBox manipulation
the closest thing to read-only is setting LimitToList property to Yes in which case it will still let them type but it won't accept anything as legal unless it is in th box.
Catching the Drop-down as an event- There are only 2 solutions and i don't recommend either of them. VBA doesn't expose this event. It has to be subclassed which i don't recommend in office.
You can simulate it the hard way by setting the box to not have a button and putting your own button next to it. (2nd solution) And the only reason you can do this is you can toggle the drop-down from code using the Dropdown procedure.
Other options to consider are using the microsoft datetimepicker control that basically is the exact control you are making the hard way. It is a combobox that shows a calendar when you click the button on it.
Re: ComboBox manipulation
Mmmmm...
I wasn't aware of the existents of the 'Microsoft DateTimePicker' control...
But it still not the best solution for my case ...I think.
First of all, it doesn't look good on XP... and by that i mean that it looks different form the other controls on the form, it looks like win2k.
Second, I sometimes like to leave a blank date. And this control always shows the current date by default.
How do I manipulate the DropDown event in this case?
Regarding the read-only, it's not the best solution for me.
Is there a way to get around this by catching the 'Change' event?
Re: ComboBox manipulation
Isn't there an option in office '03 to use xp-style buttons? i use 2k but i've used 2003 before and i'm pretty sure... Not sure if it would affect that particular control though.
Like i said you can't, in normal vba code, raise an error for the box dropping down. Your best bet in this case is to make a custom button and put it in place of the one on the combo normally. And since you have to do it this way i don't see why you would use a combo to start with. Use a standard text box with a command button next to it (with the correct arrow)
Believe me i went through the EXACT same crap you are going through. I ended up leaving the calendar displayed on the form at all times and using a standard text box linked into the database (which caused all kinds of trouble because i had that field set to datetime and null is invalid) and when you clicked a date the event i put in the control copied it into the textbox.
Re: ComboBox manipulation
I see your point.
Many thanks!