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!

On open event ? with fields 1

Status
Not open for further replies.

authorsami

Instructor
Sep 11, 2003
155
US
I have a report that I need to show a particular field only if another field has a certain value. Actually if either of two fields have a certain value.

I got how to do this on a form, but now I need to see if there is a way to do this on a Report. I have listed below what I thought the code would be.... I'm not having any luck.

Anyone have a suggestion on this one?
My report name is rptPatientDataShee
My one field is qryLeftSales.Terms
My second field is qryRightSales.Terms

the value they need to have is "Lease"
if either of these two fields say Lease I want field Text97 to be visable, if both do not say Lease I don't want the Field text97 to how at all.. If only one field says "Lease" I do want field Text97 to show. I hope this makes sense.

----
Private Sub Report_Open(Cancel As Integer)

If Reports!rptPatientDataSheet!_[qryRightSales.Terms].Value = "Lease" Or Reports!_rptPatientDataSheet![qryLeftSales.Terms].Value = "Lease" _Then
Text97.Visible = True
Else
Text97.Visible = False
End If

End Sub
----

Thanks Sharon
 
Try this:
If ((Reports!rptPatientDataSheet![qryRightSales.Terms].Value = "Lease") Or (Reports!rptPatientDataSheet![qryLeftSales.Terms].Value = "Lease")) Then
Text97.Visible = True
Else
Text97.Visible = False
End If

...and put it in the On Format Event. Not sure if your underscores were typos or not but I took them out. Sometimes when you have more than one criteria in your if statement, all of the criteria needs to be enclosed ().

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Sounds good, but I can't locate the On Format Event. Can you please point me in the right direction.....

I think I going crossed-eyed over this.

Sharon
 
In design view of the report, click on the detail section and open up the properties window. Click on the event tab and then click on the ... button on the On Format line.

Another thought on the syntax... not sure how your report is setup, but you may be able to get away with this:

If ((Me!qryRightSales.Terms.Value = "Lease") Or (Me!qryLeftSales.Terms.Value = "Lease")) Then
Text97.Visible = True
Else
Text97.Visible = False
End If

Anyone else have some thoughts on this?

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Great let me try that. I was looking on the properties of the entire report (On Open).

Sharon
 
Hip, Hip Horray!!!!

It worked, Thank you so much for your help.
Sharon
Stars headed your way.
 
Thanks and glad it worked. :)

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top