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

How do I hide a text box in my report header? 2

Status
Not open for further replies.

Rmcta

Technical User
Nov 1, 2002
478
US
I have a form with a command button and a drop down box (cboRegions).

In cboRegions the user can select(America, Europe, Asia) or leave the box empty to see all regions.
When the user clicks on the command button it opens a report for the specified region or all regions.

On the report header I have a text box called txtRegion. If the user leaves cboRegions empty, I would like to hide txtRegion on the report.

Is that possible?
If yes, how do I do it?

 
In the report header's ON FORMAT action, insert code that checks for the value of the form control, and take action based on it's contents.

iif(IsNull([Forms]![YOUR_FORMS_NAME]![cboRegions].value),me.txtRegion.visible = False,me.txtRegion.visible = True)

If the value of the form control (cboRegions) is NULL, the code above sets the text box's visible property to FALSE, otherwise it sets the property to TRUE
 
Set the control source of your txtRegion to whatever is there now plus a reference to the cboRegions
=(/whatever is there now/)+Forms!frmYourForm!cboRegions
If cboRegions is Null then the contents of txtRegion will not display.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thank you very much for your quick reply.

Here I what I now have:
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
iif(IsNull([Forms]![frmInvalidRead]![cboRegions].value), me.txtRegion.visible = False, me.txtRegion.visible = True)

End Sub

..but it gives me a compile error, syntax error ???
 
Don't use code, particularly code that won't work. If you can't get the simple expression that I suggested to work and you want to use code, try:
Code:
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
    Me.txtRegion.Visible = Not IsNull([Forms]![frmInvalidRead]![cboRegions])
End Sub

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
I thank you both.
I tried all the suggested options but they don't work.
I have decided to remove the text box.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top