Need VBA Checkbox Assistance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good afternoon,

I am using a VBA module to open an Access form. Form contains several check
boxes (made is design view, not created by code) to offer a user to select
which documents they would like to print, but
I need to know what VBA commands to use that will tell if a check box is
checked or not. I set a command button called "Print Selection" to run code
that I want to print out any documents selected. (See code below) And
procedure will compile and run, and the form opens but if I check box 29,
nothing prints in the immediate window no matter if box is checked or not. I
am curoius if I have to refresh my form or anything after that opens and I
check a box?

I think What I need to know is how to reference the checkboxes on the form,
and if they should automatically sense a change in state, or do I need to do
something for them to sense a change in state on the form? (Note check29 is
name of checkbox on form) This is my code:

DoCmd.OpenForm "Graphs Print Selection", acNormal, "", "", , acNormal
If Check29 = True Then
Debug.Print "29"
Else
END If

Do I need to use a Me.Check29 or a get command to refresh box, or how does
this know that a box is checked? What am I doing wrong? Thanks.

Cordially,
 
The code is in the Open event - it runs *before* you click the check box.
You need to move it to the After Update event of the check box.
 
This is my code:
DoCmd.OpenForm "Graphs Print Selection", acNormal, "", "", , acNormal
If Check29 = True Then
Debug.Print "29"
Else
END If
The problem is that when you open the form, the code does NOT wait, and the
"If check29 = True" is too soon.

.. You need to make the code "wait" for the form, and until the user has
finished checking all of the boxes. So, how do you know that the user is
finished?

You could move the print button to the same form. That way, the user is
free to check as many boxes, and THEN hits a print button.

You can also create a form that "waits" for user input..and then runs...

I explain how to do that here:
http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html
 

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

Back
Top