Manipulating Controls

  • Thread starter Thread starter George B.
  • Start date Start date
G

George B.

Hi,

I have a query form (screen) with two option groups
(NameOption and TitleOption) each having 3 options (AND,
OR, and NOT). There are also two corresponding text
boxes (Name and Title). When a user selects and option, I
have verbose coding to change the fore and back colors to
255 and 1677215, respectively. On the form I want to
have a button whereby the user can clear the values in
the text boxes and reset the fore and back colors to 0
and 1677215 as well as clearing the checkboxes. I can do
this by explicitly referencing each object, but that's
also verbose. How can I reference each label in the
option group controls at once to reset their colors,
clear the option, and clear the text boxes?

If anybody has a suggestion, I'd really appreciate it.
Looking at the VB Help and TechNet has given me pieces,
but I just can't put it all together.

Geo.
 
Run this code from a command button within a form containing some option
groups, then look in the debug window. That should get you started.

dim ctl as control, ctl2 as control
for each ctl in me.controls
debug.print ctl.name
if typeof(ctl) is acoptiongroup then
for each ctl2 in ctl.controls
debug.print vbtab; ctl2.name
next
endif
next

I'm not positive of the TypeOf() function name/format and the acoptiongroup
constant (and I don't have Access here to check). The intent of that line is
to see if the current control is an option group. Check online help for
similar names, if those two are not correct.

HTH,
TC
 
Back
Top