Don't show text box under certain conditions

  • Thread starter Thread starter Steven R via AccessMonster.com
  • Start date Start date
S

Steven R via AccessMonster.com

I have a form set up for the user to edit and also input new contract records
I have a drop down list that when the user picks a contractor, the form
displays certain details associated with that record, including a comments
field, viewed in the text box named "txtComments." I want the box to be
invisible if there are no comments in the box, but my code doesn't work:

If Me.txtComments.Value = "" Then

Me.txtComments.Visible = False
Else
Me.txtComments.Visible = True
End If

I've tried everything - I've tried using the source (COMMENTS) I've tried IS
NULL , IS BLANK in my IF statement - nothing works - by the way, my code is
in the ON CURRENT event of my form
 
If the contents of the text box is Null (as opposed to ""), your code won't
work.

Try the following instead:

If Len(Me.txtComments.Value & "") = 0 Then
 
Douglas said:
If the contents of the text box is Null (as opposed to ""), your code won't
work.

Try the following instead:

If Len(Me.txtComments.Value & "") = 0 Then

Or even the simpler version:

Me.txtComments.Visible = (Len(Me.txtComments.Value & "") > 0)

Hth
PerL
 

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

Back
Top