473,473 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Linking macros to checkboxes selected on an Access form

1 New Member
Hi,

I have the requirement to copy and paste the results of various queries into Excel workbooks. I've set up macros to "OutputTo" the results of each of the queries (nearly 100!) and I've set up a further macro to export them all rather one after the other than running each macro individually.

Where I'm coming un-stuck is that ideally I'd like to be able to create a form with checkboxes where the user can select which queries to run and export, click a "Go" button (or something) and this would trigger the relevant macros to run. I have a good understanding of Access but I'm not great with VBA (I can make small adjustments myself but writing from scratch is rather beyond me at the moment...) and google as hard as I might I haven't been able to find any examples of this being accomplished although it doesn't seem like a big leap from where I am now...

Please help!
Nov 30 '10 #1
1 4373
ADezii
8,834 Recognized Expert Expert
Hello Emma, actually there is a very simple solution to your problem, as long as you perform 3 Steps exactly. For this Demo, I'm assuming that you are using 10 Check Boxes, but the actual number is irrelevant, as long as you do not exceed the limit of Controls on a Form. Follow the Steps below precisely:
  1. Name your Check Boxes sequentially, as in: chk1, chk2, chk3...chk10.
  2. Name you Macros in similar fashion as in: Macro1, Macro2, Macro3...Macro10.
  3. Make sure the Labels for you Check Boxes are in sync with the Macro being called, as in: If Check Box #4 is the only one selected, and then Macro4 will run. Be sure the actual Query that Macro4 will Output is reflected in the Label for Check Box 4 (chk4).
  4. When all is done, execute the following Code which will Execute the corresponding Macro for each Check Box selected:
    Expand|Select|Wrap|Line Numbers
    1. Dim ctl As Control
    2. Dim intCtr As Integer
    3.  
    4. For Each ctl In Me.Controls
    5.   If ctl.ControlType = acCheckBox Then
    6.     intCtr = intCtr + 1
    7.       If ctl.Value Then
    8.         DoCmd.RunMacro "Macro" & CStr(intCtr)
    9.       End If
    10.   End If
    11. Next
  5. Any questions, feel free to ask.
Dec 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: trettr | last post by:
It's possible to count the checked checkboxes in a form ? If so, how? Bye Raffaele
9
by: Frances | last post by:
Hi All, * PREMISE * I'm creating an Access form with 150 items subdivided into 20 categories. Multiple categories (and items) can be selected so my user wants checkboxes. All of the options...
8
by: Colleyville Alan | last post by:
I have been working on an Access app that takes info from a file and writes it to a spreadsheet on a form, simultaneously saving the spreadsheet to Excel. I got the idea that the same concept...
1
by: RLN | last post by:
Hello. Re: Access 2003 I have a survey application that has 10 independent checkboxes on a form (chkLawnCare, chkCarpetCare, chk DrivewayMaint, etc.) One, or any combination can be checked...
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
3
by: aaa2876 | last post by:
Hello everyone! I am in the process of setting up a client contact database for my office and I have run into a bit of a snag. The database I have allows for one address per client but some of...
5
by: Tomeczek | last post by:
I'm building the application using Access 2007. I have four checkboxes on my form. Checking off different checkboxes will control the VBA routines "behind" the button. I realized, that during the...
33
tdw
by: tdw | last post by:
I have a customers table that has a couple of checkbox fields. I also have an orders table with those same checkbox fields (though with a slightly different name). This is not duplicitous as I only...
4
by: zufie | last post by:
I have two checkboxes on a form, ChckIBCCP and ChckOtherReferral. Each checkbox highlights its respective textboxes and combo boxes on the form. Many of the highlighted textboxes and combo...
0
by: jesiecraig | last post by:
Hello, I am new to VBA programming - thank you for your help. I am using a form in Access 2007 to update my database. I use a submit button on the form to send all the values into Access. I...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.