Connecting Tech Pros Worldwide Help | Site Map

Dependant Combo Box HELP

Newbie
 
Join Date: Sep 2006
Posts: 7
#1: Sep 6 '06
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
PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#2: Sep 6 '06

re: Dependant Combo Box HELP


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!
Newbie
 
Join Date: Sep 2006
Posts: 7
#3: Sep 8 '06

re: Dependant Combo Box HELP


Peb said:
Quote:

Originally Posted by PEB

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
PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#4: Sep 8 '06

re: Dependant Combo Box HELP


Whati is the run time error and on which line it appears?
Newbie
 
Join Date: Sep 2006
Posts: 7
#5: Sep 11 '06

re: Dependant Combo Box HELP


Quote:

Originally Posted by PEB

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
PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#6: Sep 11 '06

re: Dependant Combo Box HELP


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!

:)
Newbie
 
Join Date: Sep 2006
Posts: 7
#7: Sep 11 '06

re: Dependant Combo Box HELP


Peb,

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

Sincerely,

Stephen
Newbie
 
Join Date: Sep 2006
Posts: 7
#8: Sep 13 '06

re: Dependant Combo Box HELP


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
PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#9: Sep 13 '06

re: Dependant Combo Box HELP


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! :)

Quote:

Originally Posted by StevoGman

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

Newbie
 
Join Date: Sep 2006
Posts: 7
#10: Sep 13 '06

re: Dependant Combo Box HELP


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

Quote:

Originally Posted by PEB

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's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#11: Sep 14 '06

re: Dependant Combo Box HELP


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.  
Quote:

Originally Posted by StevoGman

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

Newbie
 
Join Date: Sep 2006
Posts: 7
#12: Sep 20 '06

re: Dependant Combo Box HELP


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

Quote:

Originally Posted by PEB

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.  

PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#13: Sep 21 '06

re: Dependant Combo Box HELP


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!
Reply