Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-07-2019, 06:40 PM   #1
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 325
Thanks: 26
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Function for auto dropdown for all combobox

Hi,

In a form, I have more than 20 combobox, and I would like to create a function so I on GotFocus, it will automatically dropdown that combobox.

Any idea how can I make it work instead of adding a code individually to each combobox?

Thanks

calvinle is offline   Reply With Quote
Old 11-07-2019, 06:56 PM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,721
Thanks: 57
Thanked 1,260 Times in 1,241 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Function for auto dropdown for all combobox

Hi. You might be able to create a Class Module to automatically assign that behavior to all comboboxes on a form.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 11-07-2019, 06:57 PM   #3
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,540
Thanks: 92
Thanked 1,680 Times in 1,559 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Function for auto dropdown for all combobox

Look at this article:

https://docs.microsoft.com/en-us/off...bobox.dropdown

In essence, use the .DropDown method of the combo box object, which you certainly could trigger on the GotFocus event. Not quite the same as what you requested, but it would be a one-line edit for each dropdown.

To make it totally automatic, you need to play with creating your own variant control class (i.e. some object-oriented programming.)

EDIT: theDBguy beat me to the OOP part.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Old 11-07-2019, 06:58 PM   #4
nhorton79
Newly Registered User
 
Join Date: Aug 2015
Posts: 108
Thanks: 12
Thanked 13 Times in 13 Posts
nhorton79 is on a distinguished road
Re: Function for auto dropdown for all combobox

You could do this on each Gotfocus event

Code:
Me.comboboxname.Dropdown



Sent from my iPhone using Tapatalk
nhorton79 is offline   Reply With Quote
Old 11-07-2019, 07:04 PM   #5
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 325
Thanks: 26
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Function for auto dropdown for all combobox

Quote:
Originally Posted by nhorton79 View Post
You could do this on each Gotfocus event

Code:
Me.comboboxname.Dropdown



Sent from my iPhone using Tapatalk
Yes I know but doing this I need to add the code to each individual combobox one at a time.

Thanks
calvinle is offline   Reply With Quote
Old 11-07-2019, 07:09 PM   #6
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 325
Thanks: 26
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Function for auto dropdown for all combobox

Quote:
Originally Posted by The_Doc_Man View Post
Look at this article:

https://docs.microsoft.com/en-us/off...bobox.dropdown

In essence, use the .DropDown method of the combo box object, which you certainly could trigger on the GotFocus event. Not quite the same as what you requested, but it would be a one-line edit for each dropdown.

To make it totally automatic, you need to play with creating your own variant control class (i.e. some object-oriented programming.)

EDIT: theDBguy beat me to the OOP part.
Thanks. I figure it out.
calvinle is offline   Reply With Quote
Old 11-07-2019, 07:22 PM   #7
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,721
Thanks: 57
Thanked 1,260 Times in 1,241 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Function for auto dropdown for all combobox

Quote:
Originally Posted by calvinle View Post
Thanks. I figure it out.
Hi. Does that mean you have figured it out, or does it mean you are going to figure it out? If you have figured it out, you might consider sharing your solution with others. Just a thought...

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Tera (11-07-2019)
Old 11-07-2019, 07:56 PM   #8
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 325
Thanks: 26
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Function for auto dropdown for all combobox

Quote:
Originally Posted by theDBguy View Post
Hi. Does that mean you have figured it out, or does it mean you are going to figure it out? If you have figured it out, you might consider sharing your solution with others. Just a thought...
Sure.

Basically, I created a Public Function, then I wud call that in the combobox GotFocus fire event.

Code:
Public Function ShowDropDown() As String
 Screen.ActiveControl.DropDown
End Function
I just select all the combobox, and in GotFocus, I call the function: =ShowDropDown()

Once the field has a focus, it will show the drop down.

Thanks
calvinle is offline   Reply With Quote
Old 11-07-2019, 08:08 PM   #9
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,721
Thanks: 57
Thanked 1,260 Times in 1,241 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Function for auto dropdown for all combobox

Quote:
Originally Posted by calvinle View Post
Sure.

Basically, I created a Public Function, then I wud call that in the combobox GotFocus fire event.

Code:
Public Function ShowDropDown() As String
 Screen.ActiveControl.DropDown
End Function
I just select all the combobox, and in GotFocus, I call the function: =ShowDropDown()

Once the field has a focus, it will show the drop down.

Thanks
Hi. Good job! Thanks for sharing. Good luck with your project.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 11-08-2019, 12:14 AM   #10
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,332
Thanks: 432
Thanked 790 Times in 766 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: Function for auto dropdown for all combobox

How is that any different from calling the dropdown method directly from the gotfocus event?

I can understand it if there was a lot more going on in the function, but just as it is, I cannot see any benefit.?

Quote:
Originally Posted by calvinle View Post
Sure.

Basically, I created a Public Function, then I wud call that in the combobox GotFocus fire event.

Code:
Public Function ShowDropDown() As String
 Screen.ActiveControl.DropDown
End Function
I just select all the combobox, and in GotFocus, I call the function: =ShowDropDown()

Once the field has a focus, it will show the drop down.

Thanks
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is online now   Reply With Quote
Old 11-08-2019, 03:49 AM   #11
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 6,312
Thanks: 11
Thanked 719 Times in 669 Posts
missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light
Re: Function for auto dropdown for all combobox

Because in Design View he can select all 20 Comboboxes at once...go to the OnGotFocus Property...and enter =ShowDropDown() once...as opposed to having to create 20 events, one at a time...explicitly, naming each Combobox, i.e. Me.Combo1.Dropdown, Me.Combo2.Dropdown, Me.Combo3.Dropdown etc.

Linq ;0)>
__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
Old 11-08-2019, 07:37 AM   #12
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,332
Thanks: 432
Thanked 790 Times in 766 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: Function for auto dropdown for all combobox

Ah, OK, I *thought* that multi selection trick could still be done to enter the same code in multiple controls, not just with a function.

Quote:
Originally Posted by missinglinq View Post
Because in Design View he can select all 20 Comboboxes at once...go to the OnGotFocus Property...and enter =ShowDropDown() once...as opposed to having to create 20 events, one at a time...explicitly, naming each Combobox, i.e. Me.Combo1.Dropdown, Me.Combo2.Dropdown, Me.Combo3.Dropdown etc.

Linq ;0)>

__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combobox Dropdown Type shamas21 Forms 8 07-30-2009 01:23 AM
Using ComboBox DropDown for Node Selection Ving_Rhames Modules & VBA 0 02-16-2009 12:12 PM
Stop the dropdown of a combobox sierra467 Forms 4 07-18-2007 09:50 AM
Combobox dropdown list arvindn Forms 0 10-16-2006 07:59 PM
ComboBox dropdown method bakes General 1 06-30-2006 02:55 AM




All times are GMT -8. The time now is 08:04 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World