Solved

VBA: Loop through form checkboxes

Posted on 2001-06-05
3
1,648 Views
Last Modified: 2006-11-17
Hi,

After providing my user with about 100+ checkboxes to apply criteria to a query, now she complains that it is tedious to uncheck the check boxes.

It sure would be easier to just close the form and start again, but no!

Using VBA, is it possible to loop through all the checkboxes and un-check them?

Notes:
The checkboxes are all on one form, divided into different sections on tab control pages. They only need to be unchecked.
0
Comment
Question by:sthornton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
dovholuk earned 100 total points
ID: 6158018
you could use this type of routine to uncheck ALL the checkboxes on a form:

Dim c As Control

For Each c In Me.Controls
    If c.ControlType = acCheckBox Then
        c = False
    End If
Next c

put this code behind a button (or whereever you want)

let me know if you need more help.

dovholuk
0
 
LVL 5

Expert Comment

by:vsamtani
ID: 6158042

Just put this code snippet in the OnClick event procedure for a "Clear all checkboxes" command button, or wherever else is appropriate:


  Dim ctl As Control
  For Each ctl In Me.Form.Controls
    If ctl.ControlType = acCheckBox Then ctl=False
  Next ctl




Vijay

0
 
LVL 5

Expert Comment

by:vsamtani
ID: 6158046
Ah - should have refreshed the question before posting. Anyway, it's reassuring that the two answers are identical...

:)

Vijay
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question