Group:  Microsoft Access ยป microsoft.public.access.forms
Thread: how to cycle through form combo boxes

how to cycle through form combo boxes
Daniel M 12/31/2008 7:19:01 AM
I have a form with combo boxes on it that i need to programatically cycle
through and i need some help.

on the form i have the following combo boxes
cmbo1
cmbo2
cmbo3

each combobox has the source that is a query returning a number value. i
simply return cmbo1.value to the report it works fine. but what i would like
to do is loop through this.

i would like to pull cmbox.value and loop through x.

Can someone give me some guidance on how to do this?

I tried:
for x = 1 to 3
msgbox cmbo & x.value
next x

this gives me Object required error.

if i just do msgbox cmbo & x i get a value of "1" or x but not "cmbo1".
I can do msgbox "cmbo" & x to get "cmbo1" but then i cant get the value.

I'm somewhat of a new at this so any suggestions would be great. thanks.
Re: how to cycle through form combo boxes
"Ken Snell \(MVP\)" <kthsneisllis9[ at ]ncoomcastt.renaetl> 12/31/2008 2:27:48 PM
You're close:

for x = 1 to 3
msgbox Me.Controls("cmbo" & x).Value
next x

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



"Daniel M" <DanielM[ at ]discussions.microsoft.com> wrote in message
news:2EE366DC-6891-42DB-8FE9-738C23B27745[ at ]microsoft.com...
[Quoted Text]
>I have a form with combo boxes on it that i need to programatically cycle
> through and i need some help.
>
> on the form i have the following combo boxes
> cmbo1
> cmbo2
> cmbo3
>
> each combobox has the source that is a query returning a number value. i
> simply return cmbo1.value to the report it works fine. but what i would
> like
> to do is loop through this.
>
> i would like to pull cmbox.value and loop through x.
>
> Can someone give me some guidance on how to do this?
>
> I tried:
> for x = 1 to 3
> msgbox cmbo & x.value
> next x
>
> this gives me Object required error.
>
> if i just do msgbox cmbo & x i get a value of "1" or x but not "cmbo1".
> I can do msgbox "cmbo" & x to get "cmbo1" but then i cant get the value.
>
> I'm somewhat of a new at this so any suggestions would be great. thanks.


Home | Search | Terms | Imprint
Newsgroups Reader