Need to get VBA commands to see if checkboxes on a form are select

  • 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 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 tried using an If statement like: (Note check29 is name of
checkbox on form)

If check29 = True Then
Debug.Print "Print 29"
Else
End If

And procedure will compile and run, but won't print anything in the
immediate window no matter if box is checked or not. Do I have to refresh
form or anything?
I tried to also use a boolean variable and set variable = check29 and used
that in If statement but still no difference. Should I use a Me.check29
statement instead? If so, I am not sure how to do this.

Any suggestions? Thanks.

Cordially,
 
Brent E said:
Good afternoon,

I am using a VBA module to open an Access form. Form contains several check
boxes 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 tried using an If statement like: (Note check29 is name of
checkbox on form)

If check29 = True Then
Debug.Print "Print 29"
Else
End If

And procedure will compile and run, but won't print anything in the
immediate window no matter if box is checked or not. Do I have to refresh
form or anything?
I tried to also use a boolean variable and set variable = check29 and used
that in If statement but still no difference. Should I use a Me.check29
statement instead? If so, I am not sure how to do this.

Any suggestions? Thanks.

Cordially,

I forgot to ask. I also need to now how to reference the form in my VBA
module. I defined a variable "CurrForm as Form" to use to reference my
form but I am notsure how to do that, and how to refernce any text boxes,
etc. on that form. If I can figure that out, I think I will know how
to check if the boxes are checked.
 
What event did you put the code in...???????

put a stop or breakpoint in there to see if the code runs.

I presume you click a print button or something, how about checking them
all in there prior to printing.

your code is fine, make sure check29 is not "Triple State" in the
properties as you only want 0 or -1... the event isn't firing...
 
I actually don't think I am using an event. I created a form in design view
and put many checkboxes on form. I also added a "Print Selection" command
button that runs a procedure that is supposed to print whichever documents
were checked.

I got the command button to work fine as far as finding a procedure name to
run and trying to execute that, but I tried to use a debug.print to print a
word to see if my code is recognising if Check29 is checked or not. But my
code seems to run all they way throught, but nothing prints in the immediate
window. This is my code after my declaration statements:
MESG = MsgBox("Graph Generation Complete." & Chr(10) & Chr(10) & "Would you
like to print?" & Chr(10), vbYesNo)
If MESG = 6 Then
DoCmd.OpenForm "Graph Print Selection", acNormal, "", "", , acNormal
If Check29 = True Then
Debug.Print "Print 29"
End If
But I am not sure if this knows what Check29 is referring to, and I can't
get anything to print. what amI doing wrong?
 
It almost appears by the way the code is written that your check box is on
the form Graph Print Selection. If so you would have to specify this in your
code such as forms![Graph Print Selection]![Check29]= True . You may want to
specify the other form name if it is not on that form just to test.
 

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