Visible field not working

D

dbl

Hi I have added a field called txtInFoPlus which if there is no data the
field is not visible but the fields remain visible.


The following code worked with only the txtInFo field

Private Sub Form_Current()
If IsNull(txtInFo) Then
txtInFo.Visible = False
Else
txtInFo.Visible = True
End If
End Sub

So I adjusted the code as follows with the new field txtInFoPlus but the
field txtInFoPlus field has the #Name error and both field are visible. Any
idea's what I am doing wrong ? If you take the txtInFoPlus field out of the
code you do not get the #Name error.

Private Sub Form_Current()
If IsNull(txtInFo) Then
txtInFo.Visible = False
If IsNull(txtInFoPlus) Then
txtInFoPlus.Visible = False
Else
txtInFo.Visible = True
txtInFoPlus.Visible = True
End If
End If
End Sub

Thanks Bob
 
G

Guest

Basicly, you logic construct is totally out of whack and yow are not
qualifying your control names. Also, If you would use indenting in your code
it would make it a lot more readable. Here is what I think you want.
Private Sub Form_Current()
If IsNull(Me.txtInFo) Then
Me.txtInFo.Visible = False
Else
Me.txtInFo.Visible = True
End If
If IsNull(Me.txtInFoPlus) Then
Me.txtInFoPlus.Visible = False
Esle
Me.txtInFoPlus.Visible = True
End If
End Sub

And Here is the easy way:
Me.txtInFo.Visible = Not IsNull(Me.txtInFo)
Me.txtInFoPlus.Visible = Not IsNull(Me.txtInFoPlus)
 

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

Top