473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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_AfterUpdate()
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 7129
jimatqsi
1,271 Expert 1GB
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
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 "Disposition" 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_AfterUpdate()
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 "Recondition"
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
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...
2
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...
5
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...
4
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
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
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...
1
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...
1
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)...
5
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...
0
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
jinu1996
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...
0
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,...

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.