473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide Command Button if Field Is Null

12 New Member
Hi,

I have a command button on a form that the user can use to browse to a file and the user can select that file and a hyperlink to that file is stored in a txtfield for that record.

I then have a command button that a user can click to open and view the associated file.

This all works fine. BUT:

I would like the command button that allows the user to view the file to be hidden if no hyperlink was added. In other words the txtfield for the hyperlink IsNull.

Here is what I have tried with no luck:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub txtSelectedFile_AfterUpdate()
  3. If (Me.[txtSelectedFile]) = IsNull Then
  4. cmdExplore.Visible = False
  5. Else
  6. cmdExplore.Visible = True
  7. End If
  8.  
  9. End Sub
  10.  
  11.  
Thank you!!!
Jan 12 '10 #1
14 22189
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub txtSelectedFile_AfterUpdate() 
  3.     If NZ(Me.[txtSelectedFile], "") = "" Then 
  4.         cmdExplore.Visible = False 
  5.     Else 
  6.         cmdExplore.Visible = True 
  7.     End If 
  8.  
  9. End Sub 
  10.  
  11.  
Jan 12 '10 #2
alnino
12 New Member
Thank you for the reply... But no luck. Command Button still visible when field is blank.
Jan 12 '10 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Add the Me! reference just in case there is a problem with the button name.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub txtSelectedFile_AfterUpdate() 
  3.     If NZ(Me!txtSelectedFile, "") = "" Then 
  4.         Me!cmdExplore.Visible = False 
  5.     Else 
  6.         Me!cmdExplore.Visible = True 
  7.     End If 
  8.  
  9. End Sub 
  10.  
  11.  
You should always add it anyway and if you run the debug option it will tell you if there is a problem with the reference. Otherwise check the textbox txtSelectedFile and see if it is holding any blank spaces.
Jan 12 '10 #4
nico5038
3,080 Recognized Expert Specialist
I created a hyperlink table field named "x" and used in the InCurrent event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Me.x.Visible = Not IsNull(Me.x)
  3. Me.Repaint
  4. End Sub
  5.  
And my x field was invisible when Null...

Nic;o)
Jan 12 '10 #5
alnino
12 New Member
Thank you for all of the responses.

It now works with a combination of code, using the Form_Current():
Thank you!!!
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Current()
  3.  
  4.     If Nz(Me!txtSelectedFile, "") = "" Then
  5.         Me!cmdExplore.Visible = False
  6.     Else
  7.         Me!cmdExplore.Visible = True
  8.     End If
  9.  
  10. End Sub
  11.  
  12.  
Jan 13 '10 #6
alnino
12 New Member
Thank you all for your help....

One last question:

The screen only refreshes if I advance a record and then come back. Is there a way to "refresh" or "repaint" when this txt field is either null or contains data?

I am not sure what event to use or which field to call for such an event.

Thank you
Jan 14 '10 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
In the after update event of the txtSelectedFile textbox try ...

Expand|Select|Wrap|Line Numbers
  1. Form_Current
  2.  
This will re-run any and all code in the forms current event.
Jan 14 '10 #8
alnino
12 New Member
I have tried this but no luck

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtSelectedFile_AfterUpdate()
  2. Form_Current
  3. End Sub
  4.  
Jan 14 '10 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Me.Refresh will clear out any unbound text boxes. If that is what you are trying to do. If you explain what it is you want to happen I might be able to help better.
Jan 14 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
30035
by: Xerxes | last post by:
Hi, can you tell me how I can make a <label> hidden? I have hidden the field after the label: var M_Hide = isNS4?'hide':'hidden'; var M_Show = isNS4?'show':'visible'; ..... <label id="uid">UserID: </label> <input name="UserID" type="text" value="" size="20"> <script language="Javascript1.2" type="text/javascript1.2">
10
13462
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group related to checkboxes. Thanks!!!
12
2774
by: ATS | last post by:
I need to hide/reveal parts of a web page using javascript. I think I can do with using the <span> tag, but I've been away from it for a while and don't remember. Any pointers, examples?
2
2245
by: gbb0330 | last post by:
hi all first i would like to thank PC Datasheet, i got so far because of him/her i need some help again i have this command button the on-click event procedure is
0
1815
by: Lauren Quantrell | last post by:
I use the following code to create text edit fields and command buttons in my toolbars: Function CreateToolbarObject(myObjectType as integer) Dim newObject Select Case myObjectType Case 1 'text Set newObject =
4
3516
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
7
29154
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field below the comment with a spell check & submit button. Clicking "Amend" would display the same buttons & text field but pre-populated with the original comment. Using Java Script how do I show / hide the text field in my list of comments but have...
3
2797
by: toodi4 | last post by:
I'm using a javascript that hides and unhides text based on a button click. It works great across static fields on a form. The problem I have is that I'm trying to hide and unhide various fields that are populated on the page by a database. In other words, sometimes there are 4 fields, sometimes 6. I've used various scripts for the hide/unhide function. This is one I'm using now that I've copied from another source: <script...
3
2342
by: kevinpublic | last post by:
I have an item list for ordered products on a data grid in VS 2003. It's an ASP page running VB behind it. All detail lines display as well as all shipping charges. On the edit screen, we allow them to cancel individual line items. We have the 'Cancel' button enabled for the line items of the datagrid. However, I would like to hide that button for the shipping charges. We don't want them cancelling their shipping fees, after all. ...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7475
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.