displaying checkboxes

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

Guest

I have a parameter query tied to a form, that prints its results in a report. There are many checkboxes on the form. I want the checkboxes to display in the report only if they are selected in the form. If the checkbox is not selected, I don't want it to show up on the report. Can this be accomplished using vb script?

Thanks for your help.
 
For the purposes of the code example, let's say your form's name is frmF,
and the checkboxes are chkA, chkB, and chkC, and that you have named the
checkboxes in the report with identical names. And, the form must be open
when the report is running!

In the Print event of the Report:

Dim frm as Form
Set frm = Forms("frmF")
If frm!chkA = True Then Me!chkA.Visible = True
If frm!chkB = True Then Me!chkB.Visible = True
If frm!chkC = True Then Me!chkC.Visible = True
Set frm = Nothing

For the record: The code in an Access database is VBA (Visual Basic for
Applications), not vbscript. vbscript is an interpreted language, primarily
for web pages but usable elsewhere, supported by the Windows Scripting Host
(aka Windows Scripting Runtime). I do not recommend using vbscript with
Access applications because in many shops the system administrators have
removed the WSH from all machines because of the number of viruses and worms
that use vbscript to do their mischief.

Larry Linson
Microsoft Access MVP


kimc said:
I have a parameter query tied to a form, that prints its results in a
report. There are many checkboxes on the form. I want the checkboxes to
display in the report only if they are selected in the form. If the
checkbox is not selected, I don't want it to show up on the report. Can
this be accomplished using vb script?
 
In your report go into the design mode, click in the upper
left hand corner to select the entire report. Goto
properties and under the event tab you will see the
OnPrint, click the ... and select the code option.
 
kimc said:
I'm in Access 2000 and under properties, I don't have an On Print
option under the Event tab. I have On Open, On Close, On Activate,
On Deactivate, On Data, On No Page and On Error.

Actually, it's each section of the report that has the Print event.
Select the Detail section (if that's where the check boxes are) and look
at its event properties.
 
Thanks - I found it. So, I only need to put this code in the detail section since that is the only place the checkboxes will be?
 
kimc said:
Thanks - I found it. So, I only need to put this code in the detail
section since that is the only place the checkboxes will be?

That's right, unless there's something I don't know. I'm a little
concerned that maybe we're talking about multiple records on the form,
and multiple records on the report, and you want the check boxes to be
visible not depending on the status of the form's check boxes *for the
corresponding record* -- in which case this whole approach won't work,
since the form reference will only look at the current record on the
form. But try it and see if you get what you want.
 
Back
Top