473,387 Members | 1,391 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,387 software developers and data experts.

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

Hello everybody
Actually I am a beginner with MS Access and want to make my own data base for my patients (as I am Surgeon by profession). I explain you my new query...
Suppose we have two bound combo boxes, "PositiveGPE_Finding" and "Lymphnode_Gp" respectively, in same form named "History". "PositiveGPE_Finding" combo box have value list with Multiple Selection enabled and Values; Pallor, Jaundice, Cyanosis, Lymph Nodes. Combo box "Lymphnode_Gp" has its own values. Is it possible that "Lymphnode_Gp" combo box is only enabled when 'Lmph Node' value is checked in "PositiveGPE_Finding" combo box.....
I have tried using 'ItemData' and 'Selected' properties of combo box but could not succeed....

I tried this code in the AfterUpdate()event of cbo PositiveGPE_Findings but it didn't work as well...

Expand|Select|Wrap|Line Numbers
  1. Private Sub PositiveGPE_Findings_AfterUpdate()
  2.   Dim varItem As Variant
  3.   Dim ctl As Control
  4.  
  5.   Set ctl = Me![PositiveGPE_Findings]
  6.  
  7.   If ctl.ItemsSelected.Count = 0 Then Exit Sub
  8.  
  9.   For Each varItem In ctl.ItemsSelected
  10.     Me![Lymphnode_GP].Enabled = (ctl.ItemData(varItem) = "Lymph Node")
  11.   Next
  12. End Sub
Can you help me with this....???
May 2 '11 #1
2 1260
TheSmileyCoder
2,322 Expert Mod 2GB
The ItemsSelected and varItem are for listboxes, not comboboxes.

You can test for nothing selected like so:
Expand|Select|Wrap|Line Numbers
  1. If Isnull(Me![PositiveGPE_Findings]) then Exit Sub
And use the .Value for checking whether to enable the control:
Expand|Select|Wrap|Line Numbers
  1. Me![Lymphnode_GP].Enabled = (Me![PositiveGPE_Findings].Value="Lymph Node")
A last thing to note is that .Value is the default property of textboxes and comboboxes, so if you simply write Me![PositiveGPE_Findings] it will be equivalent to Me![PositiveGPE_Findings].Value
May 2 '11 #2
I tried this code as
Private Sub PositiveGPE_Findings_AfterUpdate()
If IsNull(Me![PositiveGPE_Findings]) Then Exit Sub
Me![Lymphnode_Gp].Enabled = (Me![PositiveGPE_Findings].Value = "Lymph Node")
End Sub
but it gives Run-time error '13' Type mismatch
...............
what to do....?
May 2 '11 #3

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

Similar topics

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...
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...
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...
8
sueb
by: sueb | last post by:
I inherited a database that contains three fields: - OR Time (a number) - OR Time In Room (Date/Time) - OR Time Out Room (Date/Time) On the form is an unbounded field that correctly...
1
by: Yousaf Shah | last post by:
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...
3
by: dileshw | last post by:
I have a form where I want a third field to be autofilled by a certain text based on the content of 2 previously entered fields of data. I put this following code into an on_click event of a button....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
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...

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.