473,395 Members | 2,689 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,395 software developers and data experts.

How to hide field/s depending upon the value in other fields of same form in Access

Hello everybody!
I have started using Access very recently. I am trying to develop a database for my patients. Suppose there are three type of patients with similar fields except a few. I have placed a combo box named "Category" with drop down list containing values "Category 1", "Category 2" and "Category 3" displaying the respective category of patients. Suppose there is a field named "rank" that should only be visible if cbo.Categoey has value "Category 1"; a field named "Svc" to be visible if cbo.Categoey has value "Category 2" etc. with all other fields visible.
is it possible ?
if yes....! then
How......!!!

I will highly obliged by the response.

Thanks
Feb 24 '11 #1
1 896
Lysander
344 Expert 100+
I assume you are talking about controls on a form. I do this all the time, in my case I do not make the control invisable, I disable it, but the principle is the same.

You need to put some code in the After_Update event of your combo box.

An example from my code
Expand|Select|Wrap|Line Numbers
  1. Private Sub HadCough_AfterUpdate()
  2. On Error GoTo HadCough_AfterUpdate_Err
  3. If HadCough = 0 Or HadCough = 8 Then
  4.     HadBreathingDiff.Enabled = False
  5.     HadNoseChestIssue.Enabled = False
  6.     SeekHelpIllnessCough.Enabled = False
  7.     WhoProvidedHelpCough.Enabled = False
  8.     HowLongCareSoughtCough.Enabled = False
  9.     TakeMedicineCough.Enabled = False
  10.     WhatMedicineCough.Enabled = False
  11.     WhatDoneAntibiotic.Enabled = False
  12. Else
  13.     HadBreathingDiff.Enabled = True
  14.     HadNoseChestIssue.Enabled = True
  15.     SeekHelpIllnessCough.Enabled = True
  16.     WhoProvidedHelpCough.Enabled = True
  17.     HowLongCareSoughtCough.Enabled = True
  18.     TakeMedicineCough.Enabled = True
  19.     WhatMedicineCough.Enabled = True
  20.     WhatDoneAntibiotic.Enabled = True
  21. End If
  22. HadCough_AfterUpdate_Exit:
  23.    Exit Sub
  24. HadCough_AfterUpdate_Err:
  25.    MsgBox Err.Description & " in HadCough_AfterUpdate"
  26.    Resume HadCough_AfterUpdate_Exit
  27. End Sub
For you, you would need something like this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Category_AfterUpdate()
  2. Select Case Category
  3.   Case "Category 1"
  4.      svc.visible=true
  5.      otherfield.visible=true
  6.      thisfiedl.visible=false
  7.   Case ""Category 2"
  8.      etc etc
  9. end select
Feb 24 '11 #2

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

Similar topics

4
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email...
5
by: ND | last post by:
I need to create a separate field from 4 fields, "street address", "city", "State" and "zip code". For example, Street address - 100 Forest Street City - Seattle State - WA Zip - 05555 ...
2
by: David | last post by:
Hi, This is probably really simple but kinda has me stumped. I have taken over a data base and am looking to modify it to make it more user friendly. Currently, I have a Combo box with 4...
2
by: AA Arens | last post by:
I have two tables, one consists of company info like name and phone number. Another table where I have to fill in the contact persons. Part of the form is to choose the company he works for (From...
6
by: suresh Chowdary | last post by:
Hi All, depending upon text box entry i want to show drop down box with respective values. means if user enters 'ls' in the text box i want to show the values like 'she','he' in dropdown box it...
2
by: Matsam | last post by:
Hi, I have an ASP page that contains 3 radio buttons and a combo box. The combo box is to be populated depending on the option selected above. I am using Access DB. I want the value/checked...
2
by: ToddM326 | last post by:
I have a form (frmReport) with a list box (lstFileName) and a sub form that are not directly related, but I want to be able to store the value from the list box in one of the fields of the sub...
4
by: sade | last post by:
I want to select a column if data starts with a specific letter OR else to select from another column instead. Something like replacing columns. For example: 1st row to read columns ID, NAME if...
1
by: sillyr | last post by:
Hi I wanted to make a statement in a form to take a value from one field if the first field has no value. I have a form created from two tables. Each table has a field called Haul number. On the...
3
by: jaishu | last post by:
Hi, I have a form where user enters an ID in a text box, the ID is actually 10 digits, but even if the user enters 5-6 digits , my code is supposed to pick tht and based on tthis it should...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.