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!

Eliminating Rpt fields based on a form field entry

Status
Not open for further replies.

hytina

Technical User
Jul 24, 2003
14
US
I need to "hide" a field(s) on a report based on criteria in a form, is this possible? The fields in the report are label and line fields. If the form user enters a 2 in a field we would like to "hide" a authorization field that is not needed for this selection. There are three possible choices in the form field, each choice would change what is needed in the authorization fields of the report.

I have not had any formal training in VBA, learning as I go. I have been looking at Do..Loops. The real question is this request even possible. Any information or help will be greatly appreciated.



 
You could put code in the report. The example below would not display the ReportField on the report if the value on the form equals 2. Replace the form, textbox and label names with the ones you are using. If the test value (2) on your form is a text string rather than an actual number, you will need to place quotes around it (as "2" rather than 2).


Private Sub Report_Open(Cancel As Integer)
'Hide/Display a Label and TextBox Field on a report
If [Forms]![frmYourForm].[txtField] = 2 Then
Me.lblReportField.Visible = False
Me.txtReportValue.Visible = False
Else
Me.lblReportField.Visible = True
Me.txtReportValue.Visible = True
End If
End Sub
 
Thanks!!! I have to tell you I screamed when I seen it work. Simple fabulous.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top