requery comboboxes

N

NH

I have a form with a load of combo boxes which I need to requery when I move
between records.

Under the form|oncurrent event, I have added the lines

me.town.requery
me.city.requery
me.country.requery
me.............

what i would like to do is tidy it up a bit by adding some code which
basically requeryies *all* controls, or just the combo boxes if necessary...

Is this easy to do?

Thanks

Nick
 
N

Nikos Yannacopoulos

Nick,

Try this instead:

Dim ctl As Control
For Each ctl In Forms("Form1").Controls
If ctl.Properties("ControlType") = 111 Then ctl.Requery
Next

Note: it only requeries combo boxes (type 111) in order to exclude e.g.
labels (type 100) which would produce an error if you tried to requery.
If you want to also requery text boxes, change the line to:

If ctl.Properties("ControlType") = 111 or ctl.Properties("ControlType")
= 109 then ctl.Requery

HTH,
Nikos
 
N

NH

Perfect!

Thank you.

Nikos Yannacopoulos said:
Nick,

Try this instead:

Dim ctl As Control
For Each ctl In Forms("Form1").Controls
If ctl.Properties("ControlType") = 111 Then ctl.Requery
Next

Note: it only requeries combo boxes (type 111) in order to exclude e.g.
labels (type 100) which would produce an error if you tried to requery.
If you want to also requery text boxes, change the line to:

If ctl.Properties("ControlType") = 111 or ctl.Properties("ControlType")
= 109 then ctl.Requery

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top