Print a field only if value is true

  • Thread starter Thread starter Clay
  • Start date Start date
C

Clay

I have a 2-part question here:

1. I have a form (frmcustomerdata) with many fields on
it. I want to have a print button on the form that will
print a report for the particular record shown on the
form. Does anyone have some useful code that I can
insert into the on-click event of the print button on my
frmcustomerdata that will only print the current record
loaded on the form? Also - will this work if I have
subforms on the frmcustomerdata? (what i have is a
subform that is linked by custID to many other subforms
that also have the same custID.)

2. second, i am having a problem with check-boxes. i
have many checkboxes (yes/no) with many different
options. for example, "roof leaks?" - if the user checks
the checkbox, thus making the value = yes, I want it to
print on the report. However, if the user does not check
the check box and there is a "no" value in it, I don't
want the checkbox field to even show on the report. In
other words, only show the fields and their values on the
report if the checkbox is checked. Any suggestions and
where to begin?

I hope I have been clear enough - thanks in advance for
any advice.

Clay
 
A1 Print
See:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html
And yes, this will work correctly with the subform records, assuming the
report is based on a query that includes the table that feeds your subform.

A2 Check boxes
The problem is with the data structure. Instead of having dozens of check
boxes for various conditions, create a related table that stores the issues
that a building can have.

Structure like this:
Building table - one record for each building.
BuildingID Autonumber primary key

Issue table - one record for each type of issue.
IssueID Text (32) primary key

BuildingIssue table - one record for each combination of Building + Issue
BuildingID Number (Long) foreign key to Building.BuildingID
IssueID Text (32) foreign key to Issue.IssueID

Interface like this:
- Main form bound to Building table.
- Subform bound to BuildingIssue table.
- Subform has a combo where the Issue table is the RowSource.
User enteres as many issues in the subform as needed (one per row).
The report then contains only the issues you need, and the problem
disappears.
 
Thank you for your help. But, for the A2 - check boxes -
I think I may not have been clear.

Basically, I want the user to be able to select multiple
problems that may be related to the roof. So, for
example, my user will enter the client info on the main
form. He then jumps down to click on a tab
called "Roof". On this tab, is subform "sfrmRoof". On
sfrmRoof is a text box with a label attached
called "Shingles". The user can pick out of a few
options a condition of shingles. However, I want the
user to be able to select more than 1 option. The
shingles options may be "Leaking" and "Warped".

I wanted to just list out the options by using checkboxes
instead of combos. That way, he can just easily click
what applies...however, my problem occurs when printing
to the form. If a checkbox is left unchecked, I don't
want the checkbox, nor the label for the checkbox to
appear on the report at all.

Is this possible, or am I still being unclear?

Thanks,
Clay
 
Hi Clay.

Your explanation is not unclear, but your data structure is unnormalized.

One of the problems with the design you have is that it makes it hard to
show only the problems (exactly what you describe for your report). Another
is that it make it hard to query, "Which ones currently have an issue?",
because that query has to look at every one of the yes/no fields. Another
problem is that when you get a new kind of issue, you have to open the
table, add fields, change all your queries, change the forms, and change the
reports.

A normalized data structure will avoid not only the problem you currently
have, but all the others that you have not yet encountered. Take the time to
read up on normalization, and build the structure correctly.

As a starting point, see:
http://support.microsoft.com/?id=100139
The very first point under the "First Normal Form" heading says:
"Eliminate repeating groups in individual tables."
This means, Do not have a field for each kind of problem.

The 2nd point says:
"Create a separate table for each set of related data."
This means create a related table where the entries can be made.

In summary, we are trying to help you solve not just the problem you asked
about, but others further down the track as well.
 
Back
Top