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

Conditional formatting of a Text Box 1

Status
Not open for further replies.

rj51cxa

Technical User
Mar 16, 2006
216
GB
In the Detail section of my report I have a Text Box (Text66) which is linked to a Check Box (fInd). I have the following code in the control source of the text box:

Code:
=IIf([fInd]=True,"IND","TEAM")

This works fine but I need this Text Box to show nothing if another Text Box ([TxtName]) is blank.

I tried using the following expression in the On Open Event of the Report but each time I run it, I get the warning "You entered an expression that has no value"

Code:
Private Sub Report_Open(Cancel As Integer)
Dim varResult As Variant
varResult = IIf(Nz([TxtName]) = "", Controls("Text66").Visible = False, Controls("Text66").Visible = True)
End Sub

Could someone please advise where I am going wrong.

Thanks a lot
John
 
rjoubert

As I understand it, Nz turns a null string into a zero length string which is what I need to evaluate the argument.

Remou,

I put the following code into the Detail Format Event but I still see the text box, even though [TxtName] is blank.

Code:
If Me![TxtName] = "" Then
        Me![Text66].Visible = False
    Else
        Me![Text66].Visible = True
    End If

Best Regards
John
 
Try this...

Code:
If Me.txtName.Value = "" Then
   Me.text66.visible = False
Else
   Me.text66.Visible = True
End If
[\code]
 
Hi rjoubert,

Afraid that did not work either.

John
 
I had an idea and put Nz in front of Me![TxtName]. This worked - so problem solved.

Thanks everyone for your help. A star for Remou for giving the idea in the first place.

Best Regards
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top