I'm trying to setup a class module that will allow me to pass the form name and the types of controls that I want tested (textboxes, comboboxes, etc.) and have it test if they are populated. My thinking is that I would have a parameter that would be something like TxtCboLstChkOpt and if I wanted to only check Textboxes and Checkboxes I would pass it 10010 as flags for the class to know which types to check. My problem is that I don't know how to only run the loop once and select those types that have a 1 in their section. Normally I would have this hard coded into a Select Case statement like the following:
I don't want to have to test for the 32 different possible combinations of flags nor to I want to test each position and loop through all the controls once for each type of control for a total of five loops if all flags are checked.
I'm guessing that a bitwise comparison is going to be part of the answer, but I'm not very good with that. I wish that I could change the third line to be
so that it would add the control type to the case statement criteria. I'm just out of ideas. Hopefully I have worded my question clearly so you know what I'm looking for.
Code:
For Each ctl in Controls
Select Case ctl.Type
Case acTextBox, acCheckBox
'Perform my checks
End Select
Next ctl
I'm guessing that a bitwise comparison is going to be part of the answer, but I'm not very good with that. I wish that I could change the third line to be
Code:
Case If txt = True Then acTextBox, If cbo = True then acComboBox, etc.
Comment