UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> I Want The Text Box To Be Invisible Unless Another Text Box Has Data In It, Access 2016    
 
   
jmkeuning
post Jun 13 2019, 10:10 AM
Post#1



Posts: 140
Joined: 20-October 15



FName and FDesc

When a new record loads, both fields will be blank. FDesc will be invisible. I only want FDesc to show up if user enters data in FName.

I have this in the On Current event for the form:
CODE
Me.FDesc.Visible = Nz(Me.FName = False, True)


And this in the AfterUpdate event of FName:
CODE
If IsNull(Me.FriendlyName) = True Or Me.FriendlyName = "" Then

Me.FriendlyDescription.Visible = False

Else

Me.FriendlyDescription.Visible = True

End If


It works until I reload a record. So, starting out with both blank. I enter data in FName and then FDesc becomes visible. But when I close and reopen the form, or leave and come back to the record, FDesc is invisible.

I thought I might be misunderstanding NZ but I tried combinations of False, False, etc and it behaves the same every time.

I have only used the NZ method for showing/hiding fields based on checkboxes, so I am not sure what the best way to do this is. Any ideas for me?
Go to the top of the page
 
GroverParkGeorge
post Jun 13 2019, 10:20 AM
Post#2


UA Admin
Posts: 35,544
Joined: 20-June 02
From: Newcastle, WA


You want to know if there is a value in a control? Blank can mean two different things, so we avoid using it in this environment. A control's value is Null (no value at all) or a Zero Length String (a string of no characters). These don't mean the same thing, as you obviously know already.

Me.FDesc.Visible = Len(Me.FName & vbnullString) >0

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
GroverParkGeorge
post Jun 13 2019, 10:39 AM
Post#3


UA Admin
Posts: 35,544
Joined: 20-June 02
From: Newcastle, WA


I also avoid using IsNull(), but that's partly just a quirk of mine. In any case, you only need that one line.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
theDBguy
post Jun 13 2019, 10:46 AM
Post#4


Access Wiki and Forums Moderator
Posts: 76,081
Joined: 19-June 07
From: SunnySandyEggo


Hi. I think there's something off with this code.
CODE
Me.FDesc.Visible = Nz(Me.FName = False, True)
Try it this way:
CODE
Me.FDesc.Visible = Nz(Me.FName,"")<>""

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Jeff B.
post Jun 13 2019, 12:19 PM
Post#5


UtterAccess VIP
Posts: 10,271
Joined: 30-April 10
From: Pacific NorthWet


… and on a 'user interface' comment, I find 'disappearing/reappearing' controls to be confusing. Have you also considered using .Enabled = True/False? That way, the control is still there, but the user can tell s/he cannot enter/change a value.

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
missinglinq
post Jun 13 2019, 12:35 PM
Post#6



Posts: 4,629
Joined: 11-November 02



What's off, of course, is the function

Nz(Me.FName = False, True)

which is completely malformed! Aside from the syntax being wrong...it should be

Nz(Me.FName, "Value if FName is Null")

one would assume that FName is intended to be a String...not a Boolean (Yes/No) Field!

DBguy's example will work...as will George's!

Linq ;0)>

--------------------
Hope this helps!

The problem with making anything foolproof...is that fools are so darn ingenious!

All posts/responses based on Access 2003/2007
Go to the top of the page
 
jmkeuning
post Jun 14 2019, 12:16 PM
Post#7



Posts: 140
Joined: 20-October 15



This makes a lot of sense. Thank you!
Go to the top of the page
 
jmkeuning
post Jun 14 2019, 12:17 PM
Post#8



Posts: 140
Joined: 20-October 15



I had not thought of that, but I understand the point. I think it's easy to get carried away with appearing and disappearing boxes... Maybe I can figure out how to disable and gray out.
Go to the top of the page
 
GroverParkGeorge
post Jun 14 2019, 12:20 PM
Post#9


UA Admin
Posts: 35,544
Joined: 20-June 02
From: Newcastle, WA


Same line, slightly different syntax.

Me.FDesc.Enabled= Len(Me.FName & vbnullString)> 0

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    25th August 2019 - 07:05 AM