Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add text if True

Status
Not open for further replies.

kdoran

Technical User
Mar 23, 2003
88
US
I am trying to add text to a report if a check box is checked.

I have three check boxes

FailOpen
FailClose
FailLastState

If one of these three are checked I want to add text that says the same to a report so if FailOpen is checked it will say Fail Open.

Thanks in advance,

Kelly
 
One example:
=IIf(FailOpen, "Fail Open", ""}

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Duane,

So if the criteria is true, where do I put the IIF statement?

Kelly

 
I'm not sure what you mean by criteria. My example would be the control source of a text box on your report.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
I was referring to using a query.

Kelly
 
Using a query for what? Your initial post was "add text to a report". Are you asking a new question or is this the same? I'm not sure what you are asking.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Set up a text box on your report for each of these statements. The data source for each text box will follow the format shown already: Iif(me.FailOpen, "Fail Open", ""}
where the checkbox referenced and the text to be shown agree with what you want.

You can also make the three checkboxes hidden if you don't want to display them on the report.
 
BSman,

I will give this a try tonight at work.

Duane,

It is the same question, unfortunately I did not give enough info.

I have a report generated (multiple sheets) using a query of critical instruments which looks for a 'yes' check on critical. On the individual sheet of the report (which we use for calibration sheets) I want the text to appear "fails open" etc. only if the checkbox for one of the three is checked.

I hope this makes more sense,

Kelly
 
Reports don't have "sheets" that I am aware of. They have sections, groups, pages, headers, footers,...

Perhaps you should provide some sample data and desired output/display so we can understand your question.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Dhookom,

Sorry for the poor terminology using "sheets". What I meant was for example there are 15 critical instruments. When they were first entered into the db the person entering the data checked the critical instrument check box. When the equipment goes down for routine maintenance they can click a button on the main page (this button runs a query looking for 'yes' in the critical instrument field) and print off all 15 calibration sheets and go calibrate them.

So now we are told by our corporate office that we need to verify if the critical instruments either fail open, fail close, or fail last state. This is what I am trying to add. So when someone checks the critical instrument box, they will then choose which of the three fails it is.

I would like to add this to the query or run a sub query that goes with the critical instrument report and auto add the text needed for whichever the three they choose.

Hope this explains it a little better,

Kelly
 
We don't know critical instruments, equipment, routine maintenance, calibration sheets, etc. We do generally know tables, records, data, ...

I asked "Perhaps you should provide some sample data and desired output/display so we can understand your question."

Is this something you could provide? If not, I hope someone else who is familiar with your needs is listening.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
I will do that tomorrow or later tonight if I have time.

Kelly
 
First, did you try my suggestion? You said you would try it last night, but you didn't say if it worked or not.

Since you say that only one of the three failure modes is appropriate (or the "fourth", which would be no text), I'd suggest using a combo box that would refer to a lookup table (called "FailureStates") that would contain two columns: FailureID (autonumber column), and FailureText. Set it up so the first record is blank in FailureText with a FailureID of 1, then add the other three text descriptions. Or you could have two "none failure" records, one with the text "Not a critical instrument" and the second either blank or "Did not fail", that way you would in one field indicate if an instrument is critical or not (value over 1 if a critical instrument) and, if a critical instrument, if it failed (value over 2) and if it did fail, the failure category.

On your form create a combo box for FailureID that would only display the text and would default to a FailureID of 1 (for blank text). You could, if you want, save this in your data table with the instrument history.

When you print your calibration sheets, just print the text that goes with the value of FailureID based on the lookup table. An added advantage of this approach is that when "management" decides that the text should say "Failed when closed" rather than "FailClose", all you have to do is change the text in the lookup table once. Then all reports you print after that will display the new "better" text.
 
BSman,

Late last night I did just that, I set up a new table and added the three entries I needed, the fourth will be blank as they will not even select one of the three and I used a combo box and it worked out excellent.

I was going to try your suggestion but this came to me first but I still want to understand how to add text only if a checkbox is checked so I will still try to figure it out.

Thank you.

Dhookom,

I will give you some info:

I have a few tables

tblFieldTag
fieldtagID
EquipmentID
LocationID
LastCalibrated
Manufacturer
ModelNumber
input
span
output
critical (checkbox yes/no)
flamesafety (checkbox yes/no)
Environmental (checkbox yes/no)

etc..

tblEquipment
equipmentID
AreaID
Equipmentdescription
TypeID

There are a few more tables but don't really change the rest of this question.

OK, so I have a main menu that has multiple buttons that run queries to be able to print out information needed. So you select the critical Instrument button and it will open a form and run a query that looks for a yes in the critical column in the tblFieldTag, and if it is there it will display the individual lines in a subform on the current form. Now if you want to print off the calibration sheets (just a report of these) you press another button on the form and it will automatically print out the report which for each record will make an individual sheet. There is also a query that runs behind this button as well. This query will basically do the same as the first on and look for the same 'yes' in the critical column. If it is there it will also grab all the info needed for the calibration sheet, about half of the fields in the tblFieldTag, tblEquipment, etc..

So even though I have solved my original problem, I would still like to learn how to add another column to the report and have it look for the checkbox to add data only if it is checked. I was thinking as I might have stated in an earlier post that I may need to run a subquery in the original query to obtain this but not really sure.

Hope this info helps, and thank you in advance,

Kelly
 
For the third time:
[blue]"Perhaps you should provide some sample data and desired output/display so we can understand your question."[/blue]
I don't think we need a full table structure. It would really help if you would take the time to type in a few sample records and exactly how you want this calculated and displayed in a report.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
dhookom,

Sorry, I only added that because of the statement you had written...

We do generally know tables, records, data, ...

I realize I missed the other part of the statement.

I will type in a few sample records on Friday night as I will be off until then.

Kelly
 
Dhookom,

OK, here is some sample data

FieldTagID DCV-18008
EquipmentID 0420-L18008
Manufacturer Neles Jamesbury
ModelNumber B-fly
StoresNumber W4616163
Input 3-15 PSI
Output A/O
Critical Yes(this is a checkbox)
FailOpen
FailClose Yes(this is a checkbox)
FailLastState


Ok So what happens is this info is on a report (I explained this part on the posting on July, 7 2004.)

The report query will look for the Critical checkbox and if it is there it will add to the report.

Now what I am trying to learn how to do is look for the checkbox (with a query or other another way) in FailClose and automatically add text to the report 'Fails Close'. This would happen for all three respectively, also all three would not be checked at one time. If none of the three are checked, nothing would show up on the report.

I hope this is the info you are looking for, if not please explain.

Kelly

 
If you want the text "Fails Close" to display if any of the three check boxes are true then add a text box with this control source:
=IIf((Critical + FailOpen + FailClose)<> 0,"Fails Close","")

I hope this is what you are looking for. Just a couple points:
1) "look for Critical checkbox" is vague. The checkbox will always be there. If you are looking for the box being checked for a record then state that.
2) "add to the report" isn't too meaningful. I assume you want something displayed in a text box or label on your report.

I know this is picky and is due in part to the fact that I read hundreds of questions each week (day?).

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top