Make Text Box Invisible Unless Not Null

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help. I have a form with a textbox which is an autonumber in the
underlying table. I do not want the box to be visible until the autonumber is
in the record when the user begins to enter a record. Thanks in advance.
 
Use the form's OnDirty event to set the Visible property to True, and the
form's OnCurrent event to set it back to False.

Private Sub Form_Dirty(Cancel As Integer)
Me!YourTextBoxName.Visible = True
End Sub

Private Sub Form_Current()
Me!YourTextBoxName.Visible = False
End Sub

HTH
Sprinks
 
Sprinks, thank you very much for your very clear and concise response.

I should add additional detail as this is not quite working the way I would
like it to.

Right now I have a continuous form. So many records appear on the page. If I
use the code you provided, the autonumber does not appear for any of the
records unless the user begins to add a new record.

I want established records to show the autonumber but I do not want the user
to see (autonumber) in the text box; what I would rather do is hide it all
together unless it is not null.

Thanks for your help.
 
My belief is that what you're after is not supported, but I'll check a
reference source tonight. Failing there, I'll have to refer you to one of
the MVP's. As many of them filter posts to those that have not received a
reply, I'd suggest you repost with the initial detail contained here.

Good luck.
Sprinks
 
Did not find anything on this topic in the Access books I own, TPILGal.
Sorry. Good luck finding your answer.

Best regards.
Sprinks
 
TinleyParkILGal said:
Please help. I have a form with a textbox which is an autonumber in
the underlying table. I do not want the box to be visible until the
autonumber is in the record when the user begins to enter a record.
Thanks in advance.

I gather from your dialog with Sprinks that this is on a continuous
form. There is no direct way to support this, but you can make it
happen by covering the control with another that will hide it under the
circumstances you describe. Create another text box that is slightly
bigger in all dimensions than the original text box, and position it on
top of that control so that it completely covers it up. Then set that
text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal (or other font -- see below)
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([YourAutonumber]), String(100,"Û"),
Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the original text
box whenever the autonumber field has a Null value.

I suggested the Terminal font above because you can count on its being
present on all Windows systems and it has large block characters that do
the job on most systems. However, I am told that it doesn't give
satsfactory results on all PCs. You may want to choose a user-created
font that you can count on, and distribute it with your application.
See this link:

http://www.mvps.org/access/forms/frm0055.htm
 
re: Dirk's reply

Pretty scary stuff . . . and Halloween's almost a year away!

Gary

Dirk Goldgar said:
TinleyParkILGal said:
Please help. I have a form with a textbox which is an autonumber in
the underlying table. I do not want the box to be visible until the
autonumber is in the record when the user begins to enter a record.
Thanks in advance.

I gather from your dialog with Sprinks that this is on a continuous
form. There is no direct way to support this, but you can make it
happen by covering the control with another that will hide it under the
circumstances you describe. Create another text box that is slightly
bigger in all dimensions than the original text box, and position it on
top of that control so that it completely covers it up. Then set that
text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal (or other font -- see below)
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([YourAutonumber]), String(100,"Û"),
Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the original text
box whenever the autonumber field has a Null value.

I suggested the Terminal font above because you can count on its being
present on all Windows systems and it has large block characters that do
the job on most systems. However, I am told that it doesn't give
satsfactory results on all PCs. You may want to choose a user-created
font that you can count on, and distribute it with your application.
See this link:

http://www.mvps.org/access/forms/frm0055.htm

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top