Results 1 to 7 of 7

Thread: [RESOLVED] Hiding text box

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    58

    Resolved [RESOLVED] Hiding text box

    Hello I have a question like my last, hoping to get the same great help I did before. I am looking to put a label (a text box) in my report but I do not want it to show up if the field next to it is blank. Here's an example

    If I had a phone number I would want it to look like this:

    Phone: 970-227-1111

    The "Phone:" is the part I would have in a text box before the actual phone # I'm pulling from my database. But if in the database I did not have a phone # for that customer then I would want the "Phone:" to not show up.

    Any ideas? Thanks!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Hiding text box

    The easiest, and in my opinion, the most informative would be to leave the text "Phone" on the report. If you have a number then display it. If you do not have a number, then in the phone number text field, display "No Number Listed"

    This approach is something that, in my shop, we take on all of our reports.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    58

    Re: Hiding text box

    Quote Originally Posted by Hack
    The easiest, and in my opinion, the most informative would be to leave the text "Phone" on the report. If you have a number then display it. If you do not have a number, then in the phone number text field, display "No Number Listed"

    This approach is something that, in my shop, we take on all of our reports.
    Hack thank you for the reply. Yes this is exactly what I'm looking to do but how do I get it to change to "No Number Listed" from "Phone:" based on what the database has stored in the field?

  4. #4
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Hiding text box

    Here's how to use either approach:
    To stop the label Phone: from being displayed if the phone number field is blank, right-click on the label and select Format Text..., in the Format Editor tick the box labelled Suppress and click on the Formula button and enter a formula similar to this:
    Code:
    If Len(Trim({mytable.PhoneNumber})) = 0 Then
        DefaultAttribute
    Using Hack's approach, create a formula to display the phone number (instead of placing the field on the report) and enter code similar to:
    Code:
    If Len(Trim({mytable.PhoneNumber})) = 0 Then
        "No phone number"
    Else
        {mytable.PhoneNumber}
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    58

    Re: Hiding text box

    Quote Originally Posted by pnish
    Here's how to use either approach:
    To stop the label Phone: from being displayed if the phone number field is blank, right-click on the label and select Format Text..., in the Format Editor tick the box labelled Suppress and click on the Formula button and enter a formula similar to this:
    Code:
    If Len(Trim({mytable.PhoneNumber})) = 0 Then
        DefaultAttribute
    Using Hack's approach, create a formula to display the phone number (instead of placing the field on the report) and enter code similar to:
    Code:
    If Len(Trim({mytable.PhoneNumber})) = 0 Then
        "No phone number"
    Else
        {mytable.PhoneNumber}
    pnish,

    Thank you for your reply, I appreciate your help! I got the first example to work and that was what I'm looking for but now you gave me the idea for the second example and I think I could use it also but I can't get it to work. Here's what I got:

    Under surppress I have your code:

    If Len(Trim({mytable.PhoneNumber})) = 0 Then
    "No phone number"
    Else
    {mytable.PhoneNumber}

    It gives me an error of: The formula result must be a boolean.

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    58

    Re: Hiding text box

    Nevermind I won't need that code after all, unless you wanted to post if just in case someone else could use it.

    Thank you again for all your help!


  7. #7
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Hiding text box

    Quote Originally Posted by JSteele94
    Under surppress I have your code:

    If Len(Trim({mytable.PhoneNumber})) = 0 Then
    "No phone number"
    Else
    {mytable.PhoneNumber}

    It gives me an error of: The formula result must be a boolean.
    This code is not meant to be used as a conditional formatting formula, ie you don't use it 'Under Suppress'. It's a stand-alone formula.

    Do this:
    Show the 'Field Explorer' (View|Field Explorer), right-click on Formula Fields and then click on New... Give your formula a sensible name and then click Use Editor. Type the code I posted, save it and then close the Formula Editor. Now you just place the formula field on your report as you would a database field.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width