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

Dependant Combo Box HELP

To Whomever Can Help Me,

I am a very inexperienced programmer, and I am trying to create a combo box that is dependant on another combo boxes answer.

For example:

I have a combo box (Study Abroad), a Catvar, with three picks Yes;No;Unknown. If yes is selected then the following combo box (Study Abroad Programs) becomes availible to choose picks from. If other two picks are selected Study Abroad Programs should become greyed out.

Currently, I am going into AfterUpdate and building a event procedure containing this code:

Private Sub Combo39_AfterUpdate()
Me![Study Abroad Programs].Enabled = Me![Study Abroad] = "Yes"
End Sub

Private Sub Combo39_Current()
Me![Study Abroad Programs].Enabled = Me![Study Abroad] = "Yes"
End Sub

I keep getting a Run-Time error '438' object does not support this property or method.

Please someone, I don't know what I a doing wrong. Any help would be greatly appreciated.

Thanks,

Stephen
Sep 6 '06 #1
12 2398
PEB
1,418 Expert 1GB
Before loading your form in form view go to the properties to [Study Abroad] and check Enabled to No

Private Sub Combo39_AfterUpdate()
If Me![Study Abroad]="Yes" Then
Me![Study Abroad Programs].Enabled = True
else
Me![Study Abroad Programs].Enabled = False
end if
End Sub


Have a nice luck!
Sep 6 '06 #2
Peb said:
Before loading your form in form view go to the properties to [Study Abroad] and check Enabled to No

Private Sub Combo39_AfterUpdate()
If Me![Study Abroad]="Yes" Then
Me![Study Abroad Programs].Enabled = True
else
Me![Study Abroad Programs].Enabled = False
end if
End Sub


Have a nice luck!


I am still getting a run-time error as before. Also, shouldn't combo box Study Abroad Programs be Enabled to No? Otherwise I can't enter any data. Please any help would be greatly appreciated.

-Stephen
Sep 8 '06 #3
PEB
1,418 Expert 1GB
Whati is the run time error and on which line it appears?
Sep 8 '06 #4
Whati is the run time error and on which line it appears?
First I want to say thank you for all you help. I don't know what is going on, I must be doing something wrong. The error appears on the this line of code,

Me![Study Abroad Programs].Enabled = False

The error message is Run-Time Error '438': Object does not support this property or method.

Hopefully this information helps. Again thank you so much.

Sincerely,

Stephen
Sep 11 '06 #5
PEB
1,418 Expert 1GB
Ok!
Now try to change the code:

Private Sub Combo39_AfterUpdate()
If Me![Study Abroad]="Yes" Then
Me![Study Abroad Programs].Visible = True
else
Me![Study Abroad Programs].Visible = False
end if
End Sub

So for your [Study Abroad] Field the control is named Combo39 that isn't good at all!

Maybe the control where is bound [Study Abroad Programs] is named Combo41?

IF it is so, you have to replace Me![Study Abroad Programs].Visible with
Me![Combo41].Visible

Have a nice day!

:)
Sep 11 '06 #6
Peb,

Thank you so much. It worked perfectly. Thanks for all your help and time!

Sincerely,

Stephen
Sep 11 '06 #7
Peb,

I have another question maybe you could help me with. Here is the code I am using.

Private Sub Program_Interests_AfterUpdate()
Me![SA Programs interested in].Enabled = Me![Program Interests] = "Study Abroad"
Me![SA Programs interested in].Enabled = Me![Program Interests] = "Both"
Me![NSE Programs Interested in].Enabled = Me![Program Interests] = "NSE"
Me![NSE Programs Interested in].Enabled = Me![Program Interests] = "Both"
End Sub

What happens is, the picks "Study Abroad"; "NSE" no longer function. Instead just "Both" works. The idea being there are 4 picks Study Abroad, NSE, Both, and Unknown. So what I want is for the fields "NSE Programs interested in" and "SA Programs interested in" to only be availible to the picks NSE, Study Abroad, and Both. What I am trying to create is a dependant system with the picks. Only the code for "Both" seems to override the code for "Study Abroad" and "NSE". Any help would be greatly appreciated. Thank you so much.

-Stephen
Sep 13 '06 #8
PEB
1,418 Expert 1GB
Hi,

I don't think that this will work

1. Me![SA Programs interested in].Enabled have to be True or False and anything other

2. I don't understand what you want to do with an expression like this:

Me![SA Programs interested in].Enabled = Me![Program Interests] = "Study Abroad"

In certain languages I've seen the double equal but in VB I've never used!

If you want to set the value of

Me![SA Programs interested in].Enabled = "Study Abroad" - it is impossible!

AND to set

Me![Program Interests] = "Study Abroad"

simply write it! :)

if you want to make a condition do it as:

If Me![Program Interests] = "Study Abroad" Then Me![SA Programs interested in].Enabled=True

Hope that helps! :)

Peb,

I have another question maybe you could help me with. Here is the code I am using.

Private Sub Program_Interests_AfterUpdate()
Me![SA Programs interested in].Enabled = Me![Program Interests] = "Study Abroad"
Me![SA Programs interested in].Enabled = Me![Program Interests] = "Both"
Me![NSE Programs Interested in].Enabled = Me![Program Interests] = "NSE"
Me![NSE Programs Interested in].Enabled = Me![Program Interests] = "Both"
End Sub

What happens is, the picks "Study Abroad"; "NSE" no longer function. Instead just "Both" works. The idea being there are 4 picks Study Abroad, NSE, Both, and Unknown. So what I want is for the fields "NSE Programs interested in" and "SA Programs interested in" to only be availible to the picks NSE, Study Abroad, and Both. What I am trying to create is a dependant system with the picks. Only the code for "Both" seems to override the code for "Study Abroad" and "NSE". Any help would be greatly appreciated. Thank you so much.

-Stephen
Sep 13 '06 #9
Thanks again so much for your help, and I am sorry to bother you. I am so inexperienced! Here is another code set, that makes more sense, I used your example from before.

Private Sub Program_Interests_AfterUpdate()
If Me![Program Interests] = "Study Abroad" Then
Me![SA Programs interested in].Enabled = True
Else
Me![SA Programs interested in].Enabled = False
End If
If Me![Program Interests] = "NSE" Then
Me![NSE Programs Interested in].Enabled = True
Else
Me![NSE Programs Interested in].Enabled = False
End If
If Me![Program Interests] = "Both" Then
Me![SA Programs interested in].Enabled = True
Else
Me![SA Programs interested in].Enabled = False
End If
If Me![Program Interests] = "Both" Then
Me![NSE Programs Interested in].Enabled = True
Else
Me![NSE Programs Interested in].Enabled = False
End If
End Sub

Now, the problem is that the true false statement establed with the picks "NSE" and "Study Abroad" are no longer functioning according to the code. As if the "Both" coding is overriding them. Any help be greatly appreciated. Again, I am sorry to bother you. Thank you so much.

-Stephen

Hi,

I don't think that this will work

1. Me![SA Programs interested in].Enabled have to be True or False and anything other

2. I don't understand what you want to do with an expression like this:

Me![SA Programs interested in].Enabled = Me![Program Interests] = "Study Abroad"

In certain languages I've seen the double equal but in VB I've never used!

If you want to set the value of

Me![SA Programs interested in].Enabled = "Study Abroad" - it is impossible!

AND to set

Me![Program Interests] = "Study Abroad"

simply write it! :)

if you want to make a condition do it as:

If Me![Program Interests] = "Study Abroad" Then Me![SA Programs interested in].Enabled=True

Hope that helps! :)
Sep 13 '06 #10
PEB
1,418 Expert 1GB
Hi Steven

This time I'll suggest you other way to do this task! Using Select Case expression! This is simillar to if but more easier! See it!

Expand|Select|Wrap|Line Numbers
  1. SELECT CASE Me![Program Interests] 
  2.        CASE "Study Abroad"
  3.          Me![SA Programs interested in].Enabled = True
  4.        CASE "NSE"
  5.          Me![NSE Programs Interested in].Enabled = True
  6.        CASE "Both"
  7.          Me![SA Programs interested in].Enabled = True
  8.          Me![NSE Programs Interested in].Enabled = True
  9.        CASE Else
  10.          Me![SA Programs interested in].Enabled = False
  11.          Me![NSE Programs Interested in].Enabled = False
  12.  
  13.  
  14. END SELECT
  15.  
Thanks again so much for your help, and I am sorry to bother you. I am so inexperienced! Here is another code set, that makes more sense, I used your example from before.

Private Sub Program_Interests_AfterUpdate()
If Me![Program Interests] = "Study Abroad" Then
Me![SA Programs interested in].Enabled = True
Else
Me![SA Programs interested in].Enabled = False
End If
If Me![Program Interests] = "NSE" Then
Me![NSE Programs Interested in].Enabled = True
Else
Me![NSE Programs Interested in].Enabled = False
End If
If Me![Program Interests] = "Both" Then
Me![SA Programs interested in].Enabled = True
Else
Me![SA Programs interested in].Enabled = False
End If
If Me![Program Interests] = "Both" Then
Me![NSE Programs Interested in].Enabled = True
Else
Me![NSE Programs Interested in].Enabled = False
End If
End Sub

Now, the problem is that the true false statement establed with the picks "NSE" and "Study Abroad" are no longer functioning according to the code. As if the "Both" coding is overriding them. Any help be greatly appreciated. Again, I am sorry to bother you. Thank you so much.

-Stephen
Sep 14 '06 #11
Hey Peb,

Thankyou so much for your help. The question I have is where do I enter this code, just into VB under the variable? Or somewhere else, because I copied the code over to VB, and it isn't functioning. I am sooo sorry to bother you. Thank you soooo much for all your help!

-Stephen

Hi Steven

This time I'll suggest you other way to do this task! Using Select Case expression! This is simillar to if but more easier! See it!

Expand|Select|Wrap|Line Numbers
  1. SELECT CASE Me![Program Interests] 
  2.        CASE "Study Abroad"
  3.          Me![SA Programs interested in].Enabled = True
  4.        CASE "NSE"
  5.          Me![NSE Programs Interested in].Enabled = True
  6.        CASE "Both"
  7.          Me![SA Programs interested in].Enabled = True
  8.          Me![NSE Programs Interested in].Enabled = True
  9.        CASE Else
  10.          Me![SA Programs interested in].Enabled = False
  11.          Me![NSE Programs Interested in].Enabled = False
  12.  
  13.  
  14. END SELECT
  15.  
Sep 20 '06 #12
PEB
1,418 Expert 1GB
Hi,

No pb!

So the full code!

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Program_Interests_AfterUpdate()
  3. SELECT CASE Me![Program Interests] 
  4.        CASE "Study Abroad"
  5.          Me![SA Programs interested in].Enabled = True
  6.        CASE "NSE"
  7.          Me![NSE Programs Interested in].Enabled = True
  8.        CASE "Both"
  9.          Me![SA Programs interested in].Enabled = True
  10.          Me![NSE Programs Interested in].Enabled = True
  11.        CASE Else
  12.          Me![SA Programs interested in].Enabled = False
  13.          Me![NSE Programs Interested in].Enabled = False
  14.  
  15.  
  16. END SELECT
  17. End Sub
  18.  
Is it more clear now? This is instaed using if, something like multi if

:)

Have a nice day!
Sep 21 '06 #13

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

Similar topics

6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
6
by: Marek Mänd | last post by:
I searched google but couldnt find ant decent code for dependant comboboxes script (where the combo values in other combo depend upon the selections in the first combobox). The problem is that...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
2
by: spudpeel | last post by:
Hi, I am currently making a document control system through access, and yet another hurdle has come up. Rather than give the user a table to sift through, I want to be able to use dependant combo...
6
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help with a combo box and this same code works on my first tab with a combo box. The error or problem i have is this code causes an index out of range error when i run it on my second combo...
4
by: MyWaterloo | last post by:
Anyone give me a leg up on how to make a subform dependant on the main form's combo box selection? Thanks
4
Kitty001
by: Kitty001 | last post by:
Hi Guys I am new to MS Access and using MS Access2007. I have been fooling around with Access trying to solve this problem for weeks but i just cant seem to chack it and I need some help. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.