Pocedure for combo drop down

  • Thread starter Thread starter heat45mph
  • Start date Start date
H

heat45mph

Guest
I prefer to have combo boxes automatically dropdown for the data entry staff person, usually on got focus event I do this but I hate doing it for every combobox on my forms, sometimes i create data bases with hundres of combo boxes, I would like to write a public sub procedure to do this then call it in my form module but have been unsuccessful, anybody know the solution to this, thanks
 
Actually what you want is easier then you think. Here it is:

Create this Public Sub in a Module.

Public Sub CmbDropDown(ctr As Control)
On Error Resume Next
'Just in case the control is not a combobox
ctr.Dropdown
End Sub


After that all you need to do is add this code to any combo boxes that you want to drop down. I prefer the Enter Event:

Call CmbDropDown(Screen.ActiveControl)

by using Screen.ActiveControl this makes it generic enough so the code can easily be copied from control to control. Otherwise you have to spend the time typing in all those control names. (Note: A word of caution if you use Breakpoints to check your code always put it after a Screen proceedure as it hates to be interuped)

Hope this code makes life easier for you.
 

Users who are viewing this thread

Back
Top Bottom