Avatar of Gary Samuels
Gary Samuels
Flag for United States of America asked on

global checkboxes

Is it possible to define a checkbox in Module1, then place the checkbox on form1 making the checkbox value a global variable that can be used on form2?
Microsoft Access

Avatar of undefined
Last Comment
Gary Samuels

8/22/2022 - Mon
Dale Fye

It is probably better to leave Form1 (the one with the checkboxes) open but hidden, and refer directly to the checkboxes.  Otherwise you will have to manage 30+ global variables.

If what you are trying to do is allow the user to identify which fields to include in a query, I would recommend the multi-select list I mentioned in response to your previous question.  Would help if we knew what you were trying to do, rather than proposing a solution and asking us to help with that solution.
Gary Samuels

ASKER
Yes, I'm trying to develop a way that the user can identify which fields to include in a query. I did a quick look into the multi-select list and it told me I could not have over 20 items in the list?

My thought on the checkboxes was to have a default value of true on 6 of the most common fields. If the user did a search without opening the checkbox form these 6 fields would be included in the query. If the user wanted something different they would open the checkbox form, make their selection and run the query while the checkbox is open. When the checkbox is closed the query defaults back to the 6 common fields.
SOLUTION
Nick67

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Dale Fye

Actually, I've used the same technique recommended by Nick for a wide variety of projects.  

The advantage of his method (continuous subform with checkboxes) is that multi-select lists can be tempermental.  If you for get to hold down the ctrl or shift key, you can wipe out all of your previous selections.  With the continuous form displaying the fieldname and a checkbox,  you don't have that problem.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Nick67

Other nice advantages are that
1. The choices get stored in a table, so they don't get wiped out by a run-time error,which can happen to variables.
2. There will only be the choices selected to build your string from.  No parsing out unselected choices.
3. Many fewer controls
4. Much simpler code
Gary Samuels

ASKER
Thanks