Hiding text box in report on condition

pambroben

Registered User.
Local time
Tomorrow, 00:38
Joined
Mar 25, 2012
Messages
16
I am trying to hide a text box based on the contents of another text box in the same report. Here is the code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If IsEmpty(Me.DocFullName) Then
Me.Text55.Visible = False
Else
Me.Text55.Visible = True
End If
End Sub

i.e. I want Text55 to disappear if DocFullName is empty.

I thought my code was OK, but it refuses to co-operate. Any cluses where it's gone wrong?

Cheers,
Brodie
 
Try to use IsNull or "" instead of IsEmpty.

Code:
If IsNull(Me.DocFullName) Then
or
If Me.DocFullName="" Then
 
Like JHB says it's probably to do with your use of The IsEmpty() function.

I always use the Nz() functions as a fail safe in this type of case.

Code:
if Nz(me.DocFullName, "") = "" Then

That way you can check for null values and empty string in one command line.
 
JHB and TheBaz. Sorry guys but none of those suggestions worked .

How can I test to see if the code is actually being evaluated?

Cheers,
Brodie

STOP THE PRESS!

I think I found where my problem lies. This report is a series of letters i.e a mail merge using Access Reports only. So those fields appear multiple times.

I am not sure I can achieve what I wanted in this situation.
 
Last edited:
JHB and TheBaz. Sorry guys but none of those suggestions worked .

How can I test to see if the code is actually being evaluated?
Put in a breakpoint in your code.
How do you view the report?
You need to use "Print Preview", else your code isn't executed.
 
Got It!

1. The = "" should be = " " (with a space)
2. It only works in Print Preview or when printed . I was testing in Report View, therefore not seeing the results of the code, and driving me nuts!

Many thanks to JHB and TheBaz.
 

Users who are viewing this thread

Back
Top Bottom