Connecting Tech Pros Worldwide Forums | Help | Site Map

Text visible or not visible.

kingphillip@yahoo.com
Guest
 
Posts: n/a
#1: Nov 13 '05
Can someone help me with some code to make a text box and lable visible
only if the field in the table has something in it?

Thanks


miTch
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Text visible or not visible.


In the OnLoad Event of the form, put the code:

If isnull(me.textboxname) then
me.textboxname.visible = false
else
me.textboxname.visible = true
end if

<kingphillip@yahoo.com> wrote in message
news:1105387475.304583.238550@c13g2000cwb.googlegr oups.com...[color=blue]
> Can someone help me with some code to make a text box and lable visible
> only if the field in the table has something in it?
>
> Thanks
>[/color]


laurenq uantrell
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Text visible or not visible.


Insert this code in the form's (or report's) code module:
(Assuming that the form is bound to a table or query and assuming that
the field myfieldname is bound to a field in the table by the same
name:
example - you have a table named Contacts and in that table you have a
field named LastName. The form is bound to the table Contacts and the
field ypu want to hide or show is named LastName and is bound to the
field LastName in the Contacts table.)

Private Sub Form_Load()
If len(me!myfieldname) > 0 then
me.myfieldname.visible = true
me.mylabelname.visible = true
Else
me.myfieldname.visible = false
me.mylabelname.visible = false
End If
End Sub

Also to avoid having the field flicker when the form loads, set the
visible property of the field and the label to false so that it loads
hidden but then is made visible only if it is full.





kingphil...@yahoo.com wrote:[color=blue]
> Can someone help me with some code to make a text box and lable[/color]
visible[color=blue]
> only if the field in the table has something in it?
>
> Thanks[/color]

PC Datasheet
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Text visible or not visible.


Put the following code in the form's OnCurrent event:
Me!NameOfTextbox.Visible = Not IsNull(Me!NameOfTextbox)

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com




<kingphillip@yahoo.com> wrote in message
news:1105387475.304583.238550@c13g2000cwb.googlegr oups.com...[color=blue]
> Can someone help me with some code to make a text box and lable visible
> only if the field in the table has something in it?
>
> Thanks
>[/color]


laurenq uantrell
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Text visible or not visible.


It's best to avoid the user of If IsNull(me.textboxname) Then since it
does not handle blank rather than null strings...

PC Datasheet
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Text visible or not visible.


Just to note putting code in the Load event will only give you what you want
when the form opens. When you navigate from record to record, you will not
get what you want. Coding the form's Current event will give you what yoy
want when the form opens as well as when you navigate from record to record.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com


<kingphillip@yahoo.com> wrote in message
news:1105387475.304583.238550@c13g2000cwb.googlegr oups.com...[color=blue]
> Can someone help me with some code to make a text box and lable visible
> only if the field in the table has something in it?
>
> Thanks
>[/color]


miTch
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Text visible or not visible.


True, but the person asked "only if the field has something in it"
If it has a space in it, it contains something.
If not, If isnull will perform the function....
Not to quibble with you, it was just a quick answer.
I could write the other method as well, just longer.


"laurenq uantrell" <laurenquantrell@hotmail.com> wrote in message
news:1105388999.703715.50420@c13g2000cwb.googlegro ups.com...[color=blue]
> It's best to avoid the user of If IsNull(me.textboxname) Then since it
> does not handle blank rather than null strings...
>[/color]


Closed Thread