requery comboboxes

  • Thread starter Thread starter NH
  • Start date Start date
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
 
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
 
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
 
Back
Top