WKI
WKI

Reputation: 215

MS Access. How do I hide all text boxes in a report if one textbox data is blank

Please help. I have a report with 5 text boxes. How do i hide all the other text boxes if one text box is empty or have no data in the corresponding table field.

Upvotes: 0

Views: 1977

Answers (2)

AVG
AVG

Reputation: 1462

There is a difference between null and empty, which is why I asked about the text fields allowing empty string. I was trying to provide the simplest solution, but since you are not answering that question, here is what will work. In the format event of the detail section (or whichever section the text boxes are located) place this code.

Dim binVis as Boolean
binVis = (IsNull(Me!YourNumberFieldTextBox) Or Nz(Me!YourTextBox1,"") = "" Or Nz(Me!YourTextBox2,"") = "" Or Nz(Me!YourTextBox3,"") = "" Or Nz(Me!YourTextBox4,"") = "")
Me!YourNumberFieldTextBox.Visible = binVis
Me!YourTextBox1= binVis
Me!YourTextBox2= binVis
Me!YourTextBox3= binVis
Me!YourTextBox4= binVis

Upvotes: 0

Gustav
Gustav

Reputation: 55856

You can use code like this:

If IsNull(Me!txtbox1.Value + Me!txtbox2.Value + Me!txtbox3.Value + Me!txtbox4.Value + Me!txtbox5.Value) Then
    Me!txtbox1.Visible = False
    Me!txtbox2.Visible = False
    Me!txtbox3.Visible = False
    Me!txtbox4.Visible = False
    Me!txtbox5.Visible = False
End If

Upvotes: 1

Related Questions