G
Guest
I'm hoping that somebody knows how to do what I'm thinking is possible in my
mind.
I have a form with 25 check boxes and labels that describe each check box.
The purpose of the form is to allow the user to create a custom query that is
then executed after the user makes all desired selections by clicking the
"Submit" button. As is, the code is pretty complex to allow this
customization, joining together about 9 different strings of code. To give a
small example of how I'm doing this, I've included the following example:
If Board_Of_Health_chk = True And SqlAdditionFac = "" Then
SqlAdditionFac = "AND (((tbl_Specialties.Specialty)='Board Of Health') "
ElseIf Board_Of_Health_chk = True And SqlAdditionFac <> "" Then
SqlAdditionFac = SqlAdditionFac & "OR
((tbl_Specialties.Specialty)='Board Of Health')) "
End If
The problem I am having is that the form is somewhat dynamic and will be
changing fairly frequently. As is, everytime I need to add, delete, or
change a customizable category (such as "Board Of Health") there are a lot of
lines of code that have to be touched because I'm using specific names such
as "Board Of Health". What would be sooooo much better would be if I could
use a generic line of code that would allow me to cycle through the check box
controls one at a time to get the data I'm looking for.
To clarify:
I'm looking for code that will look at the first checkbox control on the form;
Determine if it is checked;
If it is checked, then save the check box's label into a string variable
(which I would then be able to refer to in code and append the custom code;
Then, go to the next check box control on the form
I would want this code to loop through the check box controls until it has
evaluated each one of them (another issue is how do I get the loop to stop)
If this can be accomplished - which it seems like it should be possible,
this would save me hours upon hours of form editting time and I would be very
thankful to anyone who could help.
mind.
I have a form with 25 check boxes and labels that describe each check box.
The purpose of the form is to allow the user to create a custom query that is
then executed after the user makes all desired selections by clicking the
"Submit" button. As is, the code is pretty complex to allow this
customization, joining together about 9 different strings of code. To give a
small example of how I'm doing this, I've included the following example:
If Board_Of_Health_chk = True And SqlAdditionFac = "" Then
SqlAdditionFac = "AND (((tbl_Specialties.Specialty)='Board Of Health') "
ElseIf Board_Of_Health_chk = True And SqlAdditionFac <> "" Then
SqlAdditionFac = SqlAdditionFac & "OR
((tbl_Specialties.Specialty)='Board Of Health')) "
End If
The problem I am having is that the form is somewhat dynamic and will be
changing fairly frequently. As is, everytime I need to add, delete, or
change a customizable category (such as "Board Of Health") there are a lot of
lines of code that have to be touched because I'm using specific names such
as "Board Of Health". What would be sooooo much better would be if I could
use a generic line of code that would allow me to cycle through the check box
controls one at a time to get the data I'm looking for.
To clarify:
I'm looking for code that will look at the first checkbox control on the form;
Determine if it is checked;
If it is checked, then save the check box's label into a string variable
(which I would then be able to refer to in code and append the custom code;
Then, go to the next check box control on the form
I would want this code to loop through the check box controls until it has
evaluated each one of them (another issue is how do I get the loop to stop)
If this can be accomplished - which it seems like it should be possible,
this would save me hours upon hours of form editting time and I would be very
thankful to anyone who could help.