Textbox in report

N

NewSysAdmin

Hello,
I need some help with a report. If there is no data/no records for the
report, I'd like to display the word "No" in a text box (Text150).
If there is data, I'd like to display "yes" in the same box if possible.

Here is my code in the report's no data section.

Private Sub Report_NoData(Cancel As Integer)
Report_Type_A_Report_New.Text150 = "No"
End Sub

I am not sure where to put the word "yes". As it is now, it displays "no"
even if there is data.

I also tried it another way under the Report_Open Sub. If there is no
customer name, that means there are no records:

If IsNull([Report_Type_A_Report_New.CustomerName]) Then
[Report_Type_A_Report_New.Text150 = "No"] Else:
[Report_Type_A_Report_New.Text150 = "Yes"] .

I'm not sure which way would be the best way to code it, but neither way
works as it is. I'd appreciate any suggestions. Thank you.
 
M

Marshall Barton

NewSysAdmin said:
I need some help with a report. If there is no data/no records for the
report, I'd like to display the word "No" in a text box (Text150).
If there is data, I'd like to display "yes" in the same box if possible.

Here is my code in the report's no data section.

Private Sub Report_NoData(Cancel As Integer)
Report_Type_A_Report_New.Text150 = "No"
End Sub

I am not sure where to put the word "yes". As it is now, it displays "no"
even if there is data.


You could use the Format event of the section containing the
text box:

If Me.Nodata Then
Me.text150 = "No"
Else
Me.text150 = "Yes"
End If

OTOH, it would be simpler to avoid using code and just set
the text box's evpression to:
=If(Report.NoData, "No", "Yes")
 
N

NewSysAdmin

Thank you for your response. With a little tweaking, I was able to get your
code to work. Me.NoData gave me an error, so I used the code below.

If Me.HasData Then
Me.text150 = "Yes"
Else
Me.text150 = "No"
End If

Thank you!
 
M

Marshall Barton

NewSysAdmin said:
Thank you for your response. With a little tweaking, I was able to get your
code to work. Me.NoData gave me an error, so I used the code below.

If Me.HasData Then
Me.text150 = "Yes"
Else
Me.text150 = "No"
End If


Good catch.

Sorry about that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top