473,783 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Show/Hide fields based on info in a drop down field in access 2007

2 New Member
Hello,

Can anyone help me figure out how to show/hide fields based on information entered in other fields in a form in Access 2007? What I'm looking to do is: When a selection from a drop down is chosen, hidden Yes/No fields (check boxes) that apply to that specific information appear and can be updated by users. The other Yes/No fields that do not apply to the chosen selection remain hidden.

I need to be able to do this for all the individual records in the form, but I'm having trouble figuring out how to do that.

I used the code below (as an example) in the After Update event of my drop down field to try to do this, but a.) I want all the yes/no fields hidden until a drop down selection is made and this doesnt do that and b.) it worked at hiding the inapplicable fields, but it hid those fields for all the other records and I couldnt get them back:

Private Sub Disposition_Aft erUpdate()
Select Case cboRecordType
Case "Selection 1"
Me.[Field1].Visible = True
Me.[Field2].Visible = False
Me.[Field3].Visible = False
Me.[Field4].Visible = False
Case "Selection 2"
Me.[Field1].Visible = False
Me.[Field2].Visible = True
Me.[Field3].Visible = False
Me.[Field4].Visible = False
Case "Selection 3"
Me.[Field1].Visible = False
Me.[Field2].Visible = False
Me.[Field3].Visible = True
Me.[Field4].Visible = False
Case Else
Me.[Field1].Visible = False
Me.[Field2].Visible = False
Me.[Field3].Visible = False
Me.[Field4].Visible = True
End Select
End Sub

Any help would be very much appreciated because trying to figure this out is driving me nuts :)
Jun 17 '10 #1
2 7166
jimatqsi
1,277 Recognized Expert Top Contributor
Are the checkboxes bound to a data item? If they are not, then you have a problem because unbound fields in the detail section of a form cannot be independently controlled. It is one of the most vexing things about Access.

If you have yes/no data items in the records and they are bound to the checkboxes on the screen, then what you are doing should work.

Jim
Jun 17 '10 #2
rywags11
2 New Member
Thanks! Yes, the yes/no fields are bound in a seperate table. Each of the 4 options I have in the drop down has 30+ yes/no items... so I created a seperate table for each of them and linked the ID #'s to the master table. The problem I'm having with the code I'm using is:
1.) It doesnt hide the fields until I select an option from the drop down. When a record is opened, and the "Dispositio n" field is blank, then all of my yes/no fields should be hidden
2.) Once I select an option, it hides the right fields, but it hides it for ALL of my records. I only want the option/hide&show to apply to each individual record
3.) After I select an option and the other fields are hidden, I cannot bring them back by deleting or chaning my fields. The code needs to be able to change as the selection changes

I thought about creating a subform for each option and referencing the applicable table, which will probably make this alot easier by only having to hide the subforms, but the problem I have with my subforms is it only displays the data fields in column format. I would like it to look exactly like the rest of the form, and be able to move the yes/no fields around if I want.

Here is what the code actually looks like:

Private Sub Disposition_Aft erUpdate()
Select Case cboRecordType
Case "RTV"
Me.[subRTV].Visible = True
Me.[subScrap].Visible = False
Me.[subRecondition].Visible = False
Me.[subRelease].Visible = False
Case "Scrap"
Me.[subRTV].Visible = False
Me.[subScrap].Visible = True
Me.[subRecondition].Visible = False
Me.[subRelease].Visible = False
Case "Reconditio n"
Me.[subRTV].Visible = False
Me.[subScrap].Visible = False
Me.[subRecondition].Visible = True
Me.[subRelease].Visible = False
Case Else
Me.[subRTV].Visible = False
Me.[subScrap].Visible = False
Me.[subRecondition].Visible = False
Me.[subRelease].Visible = True
End Select
End Sub

Do you have any suggestions on how I can perfect the code I'm using, and/or change the way subforms are viewed (not in columns)?

I swear I'm not a complete novice! This is just more complex than anything I've ever done!
Jun 17 '10 #3

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

Similar topics

6
148662
by: Steve Speirs | last post by:
Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected value="">Please make a selection</option> <option value="1">Choice 1</option> <option value="2">Choice 2</option> <option value="3">Choice 3</option>
2
11061
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
5
2610
by: EviL KerneL | last post by:
Hi - I am trying to figure out a way to enforce the validation included for this form based on whether the user chooses "email" or "phone" as the contact choice. Right now it is set to enforce validation on both. Is there a way to link the drop-down choice to the correspondent validation section while disabling validation for the other one? here's what I presently have:
4
2027
by: Vic Spainhower | last post by:
Hello, Access has the ability to hide the key value in a drop-down menu. Is there a way in PHP to do the same thing? Thanks, Vic
0
1210
by: jagadeesh narra | last post by:
Hi, Based on drop down value,i need to create textboxes in the same page.I should execute it in "onchange" event. Thanks Jagadeesh
2
1588
blyxx86
by: blyxx86 | last post by:
I'm attempting to remove all the garbage from being entered into a database, so I'd like to severely limit the information entered and require specific fields if a certain value is chosen.... For example.... User selects customer "Joe" and that customer requires "Tracking Number" and "Return Tracking Number" If user selects customer "Ted" but does not enter "Store Number" then they must enter an "Address".
1
1393
by: fruityfreak | last post by:
Hi everyone! I was just wondering if it's possible to do the following... And is it hard to implement such function into PHP codes... Assume that I have a drop down field whereby a user can select the different brand mobile phone i.e. Nokia, Samsung... For instance, when a user selects Nokia, another drop down field will update its values to the available Nokia models stated in the database, for example, 6300, 6500, etc will appear in...
1
4542
by: TechnoAtif | last post by:
HI.. I am looking for php code that will enable me to hide/show a text box based on the users previous drop down list response. If javascript comes into use for it, its a welcome solution (1) I want the "additional" text box to ONLY display if the user answers the drop down list with "yes" (2) If the user answers "no" to the previous drop down list I don't want the "additional" text box displayed (3) When the form is originally...
5
1707
by: Mark B | last post by:
I'd like to have a field in a gridview (or standalone on a webpage) that not only drops down each salespersons name but also precedes their name with a blue, red, green or orange dot icon depicting what group they belong to. Can drop-downs have such graphics as opposed to just text? TIA
0
1218
by: MaxVog | last post by:
Is it somehow possible to create a drop-down field similar to the following that allows the user to access each option of the drop-down menu individually by pressing a certain key combination. <select name="type"> <option value="...">...</option> <option value="...">...</option> </select> I know that <select accesskey="x"> will allow me to select the drop-down field as a whole, but not individual options.
0
9480
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,...
0
10313
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...
0
9946
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
8968
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
7494
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
6735
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();...
0
5378
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.