472,354 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

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

Nov 13 '05 #1
6 19113
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

<ki*********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
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

Nov 13 '05 #2
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:
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


Nov 13 '05 #3
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
re******@pcdatasheet.com
www.pcdatasheet.com


<ki*********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
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

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

Nov 13 '05 #5
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
re******@pcdatasheet.com
www.pcdatasheet.com
<ki*********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
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

Nov 13 '05 #6
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" <la*************@hotmail.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
It's best to avoid the user of If IsNull(me.textboxname) Then since it
does not handle blank rather than null strings...

Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Randy Starkey | last post by:
Hi, Does anyone know where I can get a script that show a little plus sign after a line of text, that when you click the plus sign, more text is revealed on that same page, like a continuing...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
6
by: Johnny Holland | last post by:
Hi, I am working on a presentation tool (Powerpoint like) that allows the user to display text over a picture background. One of the best ways to make the text stand out would be to put a black...
2
by: george.leithead | last post by:
Hi all, I have a very strange problem! In following Web page (which is generated from a CMS System), the navigation to the left 'dissapears' when you roll the mouse over the links? It does not...
0
by: grgimpy | last post by:
My form has two main text boxes that are not working correctly with the code I wrote. Upon opening the form, the operator must select a "Part Number" from a list box. Once a "Part Number" is...
3
by: Bill | last post by:
I have a report with a text box named Discount. If this text box shows a value of 0, I do not want the text box to be visible. I have tried the following code, but it disables the control even...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
3
by: msg2ajay | last post by:
hi, I am not able to align the textfield to the top of the frame one bye one. The problem is it is showing where it is hiding..... so is it possible to allign the text field to the top of...
1
by: Joshua | last post by:
I'm creating a web control that has an image and a text box. I would like to then override the Visible and Text property of the usercontrol, so when you reference the visible property of the user...
4
by: pablorp80 | last post by:
Hello, Here is what I need: I need the focus and the cursor set to a textbox named txtGT, every time no matter if it is the first page load or whether it is a postback. Here is the problem: I...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.