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!

Show or hide information based on forms checkbox 1

Status
Not open for further replies.

techsponge

Technical User
Feb 8, 2006
37
0
0
US
I have a form, with multiple tabs. On the product catagory pricing tab, I have a button that will print the product catagory price list report. This report has 5 pricing levels.

My button works great and prints the report. I have placed an unbound checkbox above each level on the form, and am trying to limit which levels will print on the report, since we do not want all customers to see the complete pricing. We may want one customer to see levels 1,2,3 and another may only see 4 & 5.


Form name: F0004_YourCompany
Tab/Page:tabCatagory
SubForm: AF01_MajorCatagory
Controls: 5 Checkboxes (chklevel1,chklevel2,chklevel3,chklevel4,chklevel5)
Report: "rptPrice List By Catagory"


I have placed the following in the OnOpen event of the report but it says it cannot find the control "chklevel1"

Code:
If Forms!F004_YourCompany!chklevel1 = True Then
Me.Level1.Visible = True
End If

Thanks in advance for any help
 
Place your code in the On Format event of the report section containing the control(s) you want to hide.

You could actually use a single line of code like:
Code:
  Me.Level1.Visible = Forms!F004_YourCompany!chklevel1

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks Duane,

Did as advised, and the report errors saying cannot find the control "chklevel1".

Just for clariffication:

chklevel1 is on:

Form name: F0004_YourCompany
Tab/Page:tabCatagory
SubForm: AF01_MajorCatagory

Thanks
 
I was able to resolve this by placing an additional 5 checkboxes on the main form and updating those based on the subform checkboxes. I refferenced the main form checkboxes in the OnFormat section of the report and all worked great!

If someone can help with with the correct syntax to refference the subform so that I can remove the 5 additional chkboxes that would be great!

Thanks to DHookom for his reply!
 
If you want to reference a control on a subform, the syntax is like:
Forms!frmMainForm!sfrmName.Form!txtControlName

This assumes your subform control name on your main form is the same as the subform name. When you place a subform onto a main form, the name of the subform control generally defaults to the name of the subform.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
A star for you!!!

I was assuming the name of the form was what I was seeing in design mode, when in fact it was 'child19'.

Fixed the name of the subform and all is well, thanks as always!
 
Glad you caught the issue. It's difficult to explain the differences between the name of the subform contol and the name of the control on the subform and the name of the subform....

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top