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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make check boxes on form determine fields in report?

Status
Not open for further replies.

Maine

Technical User
Feb 4, 2001
41
0
0
US
I'm trying to design a database that has several fields (text and memo) each will have a check box. If the check box is checked, then the content will print in the report. The finished report is going to be a proposal saved to Word. I've done keyword searches in various forums and have found similar questions but none exactly like what I'm trying to do. I'd appreciate any help - very, very simple instuctions would also be appreciated.
Thanks so much.
 
In design view of the form, open properties, click on the check box, then scroll down to On Click event of the check box, enter the following:

DoCmd.OpenReport "ReportName",acNormal ' this will print the form

DoCmd.OpenReport "ReportName" acViewPrieview ' this will just open the report to be previewed

HTH

Maurie

P.S. you may want to consider using an option group, also, the above code will not change the box checked when you return. An investment in knowledge always pays the best dividends.

by Benjamin Franklin
 
I haven't tried your suggestion yet but could you explain how that code will print the contents of a text box based on a check in a check box?
 
Maine,

Based on your second question, maybe I don't understand what you have & trying to accompolish. I have re-read your original question several times and this is what I think (now)you are asking. If I am off base, please let me know because my original answer assmued only one check box would be checked and then printed when checked.

You have a form with, let's say 10 check boxes. If 4 are checked and 6 not, then you want a report based on the 4 ithems that are chceked. In addition, there is a button, at the end, when clicked, will print the report. An investment in knowledge always pays the best dividends.

by Benjamin Franklin
 
Sorry that my original question was not clear. I found an answer on another website, may I run it by you? I have 10 checkboxes with 10 text boxes and when some or all are checked I want the text boxes to print in the report. The solution I found is to add a text box on the report with the added statement of Iif([checkbox1]=True,[textbox1],""). This works great. The next problem I have is that I want the ten (+/-) text boxes that print in my report to be consecutively numbered - difficult because the text boxes could change based on which ones are checked. My goal is a proposal which is set up in outline format. Your thoughts are appreciated.
 
Sorry I haven't gotten back to you, but have been inundated with snow. Part of the solution seems to be a workable one. As for numbering consecutively, that will require more thought (if it can be done based on your requirements). You most likely could use the same If statement concept for numbering. You would have to create 10, unbound, text boxes for the numbering and create if statements for each. Box 1 -- if([checkbox1]=True,"1",If([checkbox1] = False............,"").

If by now you have found a solution, please post to let me know. An investment in knowledge always pays the best dividends.

by Benjamin Franklin
 
Oh mph1 I have not found a solution yet. I am sorry about your snow (being from Maine, I can relate). I don't know if an If statement will work because say for example the first item could be numbered 1 or not (that's easy) but the second item could be numbered two, one or nothing. The third item could numbered be three, two, one or nothing etc. If the If statement is based on the checkbox, I only have two options - don't I? I wish I could find an example somewhere of something similar, I've looked at the Northwinds database and others that I've collected over the years and can't find anything similar. Your input is appreciated. Stay safe, warm and dry.
 
Hi Maine,

I appreciate your thoughtfullness and understanding. Snow for us is not that big a problem, but when you get 26" at once, then 2" of rain two days later coupled with high winds -- well that's a bit much. Fortunately, the temp didn't go much above freezing for a few days and will be back in the teens or lower the bal. of the week. The snow we just got combined with what was already there caused concern about flooding. Anyway, your dilemma.
After you create the 10 unbound text boxes on the form (these are for numbering purposes only)try using the IF statement in the control source of each. As you say, the first one isn't that difficult. As you go along, you will need to use the AND in the IF statement. It will be rather complex (haven't tried myself) but should work.
Example for text box 3
IF([TextBox1] =true and [textbox2]=false,"2",..... add more if's. When you get to box 10, that will be the longest statement because of the number of possibilities.
If you find an easier way, I would value knowing how you accompolished.

Good Luck!

Maurie An investment in knowledge always pays the best dividends.

by Benjamin Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top