automating process using combobox values-using a loop

I have a combobox(cboEntry) with 5 entries-A,B,C,D,E.( value list) not table/query
currently everything is manually process. I have to select a value in a combo box then click the command button and it processed accordingly the criteria. However I would like to automate the process. Instead of selecting an item in the combo box and executing using it, I would like to loop throug the values and excute the code behind the click event of the command button. Is that possible? sometthing like

....  For i = 0 To Me.lstMod.ListCount - 1 but in my case it is a combo box....
           call cmdExt_click

Can someone show me the code to get this accomplish?
Im debating whether I will use the call to the cmdExt_click or call the modulles currently inside the command button.
Im also debating whether use a listbox instead of combo box.

thanks in advance!

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi zachvaldez,
So it sounds like the combo box has no purpose. You can hold the list in memory.

You need some looping code such as ...

Dim arr(4)
Dim x
arr(0)= "A"

For x = 0 to 4
' do something using arr(x)
next x

zachvaldezAuthor Commented:
well,  the combo box or listbox is needed to display what is going on.. although it is automated
Dim ctl as combobox
Dim intIndex as integer

 Set ctl = Me!YourComboBox
' Loop through all combo box rows; run your process passing the current combobox value as a parameter
For intIndex = 0 To ctl.ListCount - 1
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

zachvaldezAuthor Commented:
I was wondering how the function would look like.


should I say Myfunction(ctlm as combo box , i as integer)

is this right?
Since your combobox entries are text the function would look like this:

YourFunction(strComboBoxValue as String)

You are only passing the value in the combobox to your function (or procedure). This line of code: ctl.ItemData(intIndex)), retrieves the value of the combobox on a particular row.  So your function just needs to have a parameter that accepts the value from the combobox.

The whole thing might look like this:

Sub CommandButton1_Click

    Dim ctl as combobox
    Dim intIndex as integer

    Set ctl = Me!YourComboBox
    'Loop through all combo box rows; run your process passing the current combobox value as a parameter
    For intIndex = 0 To ctl.ListCount - 1

End Sub

Function YourFunction(strComboBoxValue as String)
   <<<<  Your process >>>>
End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zachvaldezAuthor Commented:
In form load..
I would like the combo bx to default to the first value list..
how is that done?
Here is how you can select the first item:

Me.YourComboBox = Me.YourComboBox.ItemData(0)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.