Click to See Complete Forum and Search --> : [RESOLVED] Hiding text box
JSteele94
Oct 11th, 2005, 05:34 PM
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!
Hack
Oct 12th, 2005, 05:52 AM
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.
JSteele94
Oct 12th, 2005, 09:14 AM
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?
pnish
Oct 12th, 2005, 04:38 PM
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:If Len(Trim({mytable.PhoneNumber})) = 0 Then
DefaultAttributeUsing Hack's approach, create a formula to display the phone number (instead of placing the field on the report) and enter code similar to:If Len(Trim({mytable.PhoneNumber})) = 0 Then
"No phone number"
Else
{mytable.PhoneNumber}
JSteele94
Oct 13th, 2005, 09:28 AM
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:If Len(Trim({mytable.PhoneNumber})) = 0 Then
DefaultAttributeUsing Hack's approach, create a formula to display the phone number (instead of placing the field on the report) and enter code similar to:If Len(Trim({mytable.PhoneNumber})) = 0 Then
"No phone number"
Else
{mytable.PhoneNumber}
pnish,
Thank you for your reply, I appreciate your help! :thumb: 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.
JSteele94
Oct 13th, 2005, 02:13 PM
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!
:bigyello: :wave:
pnish
Oct 13th, 2005, 03:22 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.