Hide / Display text boxes and labels in form

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

Steven R via AccessMonster.com

This should be so simple - I'm working on a contract database that either has
a contract number or a PO number - if the contract number field is empy, I
want to hide the text box and associated label, and show the PO number text
box and assoc. label - here is my code:

Private Sub Detail_Click()

If Me.txtContractNum.Value Is Null Then

Me.txtContractNum.Visible = False
Me.lblContractNum.Visible = False

Else
Me.lblPONum.Visible = True
Me.txtPOnum.Visible = True
end if
end sub

I tried Private SubDetail_Format() but that didn't work either

Steve
 
S

Steven R via AccessMonster.com

Thanks, Lynn
Actually, I forgot to mention that I had code to hide buttons on open - it
blew up on me as soon as I opened the form - possibly my fault - but I asked
someone else, and they gave the same suggestion, so you were probably right -
I just need to do some troubleshooting
STeve

Lynn said:
Try putting that code in the Current event of your form.
This should be so simple - I'm working on a contract database that either
has
[quoted text clipped - 19 lines]
 
S

Steven R via AccessMonster.com

I got error '424' - Object Required - here's my code:

Private Sub Form_Current()

If Me.txtContractNum.Value Is Null Then

Me.txtContractNum.Visible = False
Me.lblContractNum.Visible = False

Else
Me.lblPONum.Visible = True
Me.txtPOnum.Visible = True

.... it blows up on this line:

If Me.txtContractNum.Value Is Null Then

End If



End Sub


Steven said:
Thanks, Lynn
Actually, I forgot to mention that I had code to hide buttons on open - it
blew up on me as soon as I opened the form - possibly my fault - but I asked
someone else, and they gave the same suggestion, so you were probably right -
I just need to do some troubleshooting
STeve
Try putting that code in the Current event of your form.
[quoted text clipped - 3 lines]
 
L

Lynn Trapp

Change your code to

If IsNull(Me.txtContractNum) Then

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Steven R via AccessMonster.com said:
I got error '424' - Object Required - here's my code:

Private Sub Form_Current()

If Me.txtContractNum.Value Is Null Then

Me.txtContractNum.Visible = False
Me.lblContractNum.Visible = False

Else
Me.lblPONum.Visible = True
Me.txtPOnum.Visible = True

... it blows up on this line:

If Me.txtContractNum.Value Is Null Then

End If



End Sub


Steven said:
Thanks, Lynn
Actually, I forgot to mention that I had code to hide buttons on open -
it
blew up on me as soon as I opened the form - possibly my fault - but I
asked
someone else, and they gave the same suggestion, so you were probably
right -
I just need to do some troubleshooting
STeve
Try putting that code in the Current event of your form.
[quoted text clipped - 3 lines]
 

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