473,789 Members | 2,683 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
14 22193
alnino
12 New Member
msquared,

I have command button on a form that allows a user to browse to a file (doc, pdf, etc..)
The user chooses that file and a hyperlink for that file is stored in a txt field for the table

Then on the form there is a command button that allows the user to click and open the hyperlinked file.

Currently it is set up so if the hyperlink field is empty, the command button to view a file is not visible

This all works fine.

The ONLY issue is if:
The user clicks and adds the hyperlink; the “view” button is not visible until the user advances one record on the form and then goes back to the record in question.
Jan 14 '10 #11
MMcCarthy
14,534 Recognized Expert Moderator MVP
Put the Form_Current command at the end of the code that adds the hyperlink to the field. It doesn't work in the AfterUpdate event because you never tab into that field so the event never triggers.
Jan 14 '10 #12
alnino
12 New Member
msquared,

I have put the Form_Current at the ned of the code to add the hyperlink... since no luck making the "View File" command button visible unless advance record and go back...umm...

Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdBuildingAdd_Click()
  2.  
  3. Me!txtSelectedFile = BrowseFiles()
  4.    variable = Me!txtSelectedFile
  5.  
  6. Form_Current 
  7.  
  8. End Sub
  9.  
Jan 15 '10 #13
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
While what you have posted will certainly work, it might clutter up things latter if you wish to add other code to your Form_Current that you might not like running after uses adds his hyperlink.

Instead add a procedure to your form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub setLinkVis()
  2.     If Nz(Me!txtSelectedFile, "") = "" Then 
  3.         Me!cmdExplore.Visible = False 
  4.     Else 
  5.         Me!cmdExplore.Visible = True 
  6.     End If 
  7. End Sub
Then change your code to:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdBuildingAdd_Click() 
  2.  
  3. Me!txtSelectedFile = BrowseFiles() 
  4.    variable = Me!txtSelectedFile 
  5.    call setLinkVis
  6.  
  7. End Sub 
And in your Form_Current:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current() 
  2.    call setLinkVis
  3. End Sub 
Jan 15 '10 #14
alnino
12 New Member
TheSmileyOne,

That did it. THANKS!!!
Jan 15 '10 #15

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

Similar topics

2
30036
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
2775
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
3518
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
29155
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
9666
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
10408
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
10139
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
9983
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...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
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
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
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

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.