Evaluating multiple option buttons on a subform

E

ecwhite

Hello,

I have a tab control with 8 pages with a subform 1 for each comitte that i
am collecting data for

I only want to run the code to select the max auto number 1 time if atleast
one of the add to committe option button is selected. If none is selected no
need running the query to pull the max number. It will just enter the basic
information in the main table with nothing going into any of the commitee
tables.

What is the easiest way to check if any of the 8 option buttons on each page
on a tab control is selected? they have different names . My current code
alwas default to nothing

Please note that the different option buttons are for different items so i
don't need an option group

Eg.

If Me.sub_frm_name.Controls("opt_add_case_to_comm1").Value Or
Me.sub_frm_name2.Controls("opt_add_case_to_comm2").Value Or
Me.sub_frm_name3.Controls("opt_add_case_to_comm3").Value Or
Me.sub_frm_name4.Controls("opt_add_case_to_comm4").Value = True Then

Run my code to pull max number

Case which one is selected

I want to check if it is option 1 or 2 or 3 through 8 is selected so as to
run the correct append query for each one b/c field names are different

End Case

End If

Hopefully this makes sense.
 
M

Marshall Barton

ecwhite said:
I have a tab control with 8 pages with a subform 1 for each comitte that i
am collecting data for

I only want to run the code to select the max auto number 1 time if atleast
one of the add to committe option button is selected. If none is selected no
need running the query to pull the max number. It will just enter the basic
information in the main table with nothing going into any of the commitee
tables.

What is the easiest way to check if any of the 8 option buttons on each page
on a tab control is selected? they have different names . My current code
alwas default to nothing

Please note that the different option buttons are for different items so i
don't need an option group

Eg.

If Me.sub_frm_name.Controls("opt_add_case_to_comm1").Value Or
Me.sub_frm_name2.Controls("opt_add_case_to_comm2").Value Or
Me.sub_frm_name3.Controls("opt_add_case_to_comm3").Value Or
Me.sub_frm_name4.Controls("opt_add_case_to_comm4").Value = True Then

Run my code to pull max number

Case which one is selected

I want to check if it is option 1 or 2 or 3 through 8 is selected so as to
run the correct append query for each one b/c field names are different

End Case

End If


Will this do what you want:

Select CaseTrue
Case Me.sub_frm_name.opt_add_case_to_comm1
'Append to tbl 1
Case Me.sub_frm_name.opt_add_case_to_comm2
'Append to tbl 2
. . .
Case Else
' none were selected
End Select
 
E

ecwhite

Thanks Marshall. I will try it and let you know.

Marshall Barton said:
Will this do what you want:

Select CaseTrue
Case Me.sub_frm_name.opt_add_case_to_comm1
'Append to tbl 1
Case Me.sub_frm_name.opt_add_case_to_comm2
'Append to tbl 2
. . .
Case Else
' none were selected
End Select
 
E

ecwhite

Thanks a lot Marshall.

It worked but I had to add the .value = "1" to it because it was defaulting
to the first option even when True is not selected because the default is 2
so it reads it as selected.
 

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