Text visible or not visible.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kingphillip@yahoo.com

    Text visible or not visible.

    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

    #2
    Re: Text visible or not visible.

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

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

    <kingphillip@ya hoo.com> wrote in message
    news:1105387475 .304583.238550@ c13g2000cwb.goo glegroups.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]


    Comment

    • laurenq uantrell

      #3
      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!myfieldn ame) > 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...@yah oo.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]

      Comment

      • PC Datasheet

        #4
        Re: Text visible or not visible.

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

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





        <kingphillip@ya hoo.com> wrote in message
        news:1105387475 .304583.238550@ c13g2000cwb.goo glegroups.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]


        Comment

        • laurenq uantrell

          #5
          Re: Text visible or not visible.

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

          Comment

          • PC Datasheet

            #6
            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@pcdata sheet.com



            <kingphillip@ya hoo.com> wrote in message
            news:1105387475 .304583.238550@ c13g2000cwb.goo glegroups.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]


            Comment

            • miTch

              #7
              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" <laurenquantrel l@hotmail.com> wrote in message
              news:1105388999 .703715.50420@c 13g2000cwb.goog legroups.com...[color=blue]
              > It's best to avoid the user of If IsNull(me.textb oxname) Then since it
              > does not handle blank rather than null strings...
              >[/color]


              Comment

              Working...