473,883 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make a button in/visible depending on a control's value?

379 Contributor
I have a form (which is used as a Continuous subform) that has a button on it that calls up a separate, more detailed form for the the particular record's. However, I want that button to appear only when the Account Number in the subform actually has a value, so I was hoping that it would be visible in all the forms that were displaying an existing record, and not visible in the "*" form (the "add" instance, at the bottom of the series of forms).

May 19 '11 #1
8 11980
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi again Sue. You can use your continuous form's On Current event to set the state of your control's visible property as follows:

Expand|Select|Wrap|Line Numbers
  1. Me![your button control name].Visible = Not(Me.NewRecord)
The NewRecord property of the form is only true when you are on a new record - in which case the On Current event would set the control not to be visible. On every existing record the NewRecord property is false, so the control would be visible.

A caution: if your control is on the detail section of your continuous form (i.e. it is on each record) this approach will not work as you expect, because Access uses a single control instance repeated over all the rows displayed - so the control will literally be removed or made visible again on all the rows of your continuous form simultaneously.

May 19 '11 #2
379 Contributor
Ah, so it sounds like I can't get what I want, which is to have the button not visible until the user has actually created the new record.

Well, thanks for this very complete explanation, Stewart! It may very well come in handy in a future instance.
May 19 '11 #3
4 New Member
One note on this - you CAN specify the control for the current record in the detail section of a continuous form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub ShowHide()
  2.      'Make sure looking at correct record of course..
  3.      DoCmd.RunCommand acCmdSelectRecord
  4.      MyButton.Visible = Not(Me.NewRecord)
  5. End Sub
That part of selecting the record may not be correct, I forget, and don't have my examples in front of me at the moment.
May 19 '11 #4
379 Contributor
kjv 1611, so where would this go? I mean, what event for the Detail? Or, I guess, how would this get activated?
May 19 '11 #5
4 New Member
Whichever code you're using to set the control to visible/invisible.

The "Detail" we're talking about is the Detail section of the form. On a continuous form, the detail section is where the changing list of records is listed. So if you have 100 records, you may have 10 of them on the form at a time, for instance.

Post back to acknowledge whether that makes sense to you or not. I may not be on here much longer - at least for this weekend.
May 19 '11 #6
379 Contributor
But it has to go in an event, right? I sort of tried some stuff in the On Open and On Load events, but what I was trying didn't really work.
May 19 '11 #7
32,584 Recognized Expert Moderator MVP
I can only assume kjv1611 is confusing what has been said. My best guess is that they're saying that access to the current record is possible (which is correct), but the point here appears to have been missed, which is that whenever the control is updated to reflect the current record, all the instances of the control on the form reflect that update. Essentially Stewart is absolutely correct in every detail (which will be no surprise to any that know him - a bit of a class swot :-D). More explanation on this subject can be found at Why Values in Unbound Form Controls do not Persist.
May 19 '11 #8
379 Contributor
Thanks, NeoPa! (hmmm... it says i need 40 characters)
May 19 '11 #9

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

Similar topics

by: brian4cards | last post by:
http://www.igearonline.com/subscribe/admin.asp I created a table that is filled with database records. On each row of the table I have a delete submit button to delete that record. I need to associate one of the database fields with the delete button so I can send that information back to the server side. Something like: <input type="submit" name="delete" value= <% =rs.Fields(6) %> /> Then on server side i can do...
by: PCB | last post by:
Hi all, Not sure if this is possible, but can I change the controls of a command button on a per record bases in a subform. In my case, I would like to make a command button visible only if certain fields in a table are a certain value. The buttons are adjacent to each record (i.e. - if there are 5 records, there would be 5 buttons; 10 records, 10 buttons; etc.) Here is the subroutine I've written so far: Public Sub IsButtonVisible()
by: Dave | last post by:
I have a button on Form1 that hides the form and displays Form2: Form2 myForm2 = new Form2(); myForm2.Show(); this.Hide(); After I do some work in Form2 I want to close it and redisplay Form1. I can close the form with: this.Close();
by: jayuya | last post by:
How can i check in java script if a asp.net radio button list server control is selected? I have some custom javascript function in the client side that needs to run but I don't see the way to see if user selected or not one of the options.... thanks, jayuya
by: Imran Aziz | last post by:
Hello All, I have an asp:linkbutton in a repeater control, what I want to do is when someone clicks the link button I should get a value for the link button, and accordingly do some action. How can I do that, can someone please help me with that. Imran.
by: riteshjain82 | last post by:
Hi, I am maintaining a site which is written in ASP. Now i have to create some new pages. In one page we have a table with many rows. Now, I want to enable or disable(showing and hiding also) 2 rows of this table depending upon the value selected by the user from a drop down list. Can somebody please help me??? This is really urgent.....
by: keithb | last post by:
I have a GridView control that has a delete button (hyperlink) in one column. The datasource table contains a column that has a true/false indicator showing whether or not the record can be deleted. How can I enable/disable the delete button depending on the value of the indicator? Ideally, I would like to make the button invisible where a record cannot be deleted. Thanks, Keith
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables Forms and Family and the associate table is called Forms_Family. Forms_Family have fields "dateSent" and "dateReceived". The Family table has a field called
by: Doogie | last post by:
Hi, I am trying to access the visible property of an ASP button inside javascript to no avail. Here's what my button control looks like: <asp:Button id="btnAcceptTrips" name="btnAcceptTrips" runat="server" Text="Accept Trips" Visible="False"> Here's my test method: function test(checkbox)
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.