By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

cascade combobox problem.

P: 99
I have two comboboxes on a subform.The first combobox is used to populate the second combobox.These are placed in the detail section of the form.I want them to work this way:when I select any value from the first combobox,I want the second combobox of the same row to get populated by relevant value.
As of now, I have tried to implement this and as I select any value from the first combobox of row 1 I see the second combobox of the same row gets populated but as I go on selecting values from the first set of comboboxes I see that the values in the second set of the comboboxes above changing or becoming null.
Here's the code:
The 1st combobox is cboRCMTask:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboRCMTask_AfterUpdate()
  2.     Me.cboRCMTaskOptions.RowSource = "SELECT ID, RCMTaskOptions FROM tblRCMTaskOptions WHERE RCM_ID=" & Me.cboRCMTask.Column(0) & ";"
  3.     Me.cboRCMTaskOptions = Me.cboRCMTaskOptions.ItemData(0)
  4.     Me.cboRCMTaskOptions.Requery
  5. End Sub
cboRCMTaskOptions is the second combobox.

The form_current event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.cboRCMTask.RowSource = "SELECT ID, RCMTask FROM tblRCMTask;"
  3.     If IsNull(txtRCM_ID) Then
  4.         Me.cboRCMTask = Me.cboRCMTask.ItemData(0)
  5.         'Me.cboRCMTask = Null
  6.     End If
  7.     Me.cboRCMTaskOptions.RowSource = "SELECT ID, RCMTaskOptions FROM tblRCMTaskOptions WHERE RCM_ID=" & Me.cboRCMTask.Column(0) & ";"
  8.     If IsNull(txtRCMOption_ID) Then
  9.         Me.cboRCMTaskOptions = Me.cboRCMTaskOptions.ItemData(0)
  10.     End If
  11. End Sub
Apr 19 '12 #1
Share this Question
Share on Google+
8 Replies


Expert 100+
P: 634
Hi

I have three obsevations:

1. You have not said whether the comboboxes are bound to a control in the details section, if so, this could be the problem for cboRCMTaskOptions if the new Row Source does not contain the current (bound) value.

2. I would place the Form_Current code you have in the Form_Load event as, as fare a I can tell, this is not record dependant!!?

3. I think I would requery cboRCMTaskOptions BEFORE assigning it a value!?

Without knowing more about the data/table relations/binding this could all be irrelevant!!

MTB
Apr 19 '12 #2

P: 99
1.cboRCMTast is bound to RCM_ID and cboRCMTaskOptions is bound to RCMOptionID.
2.I have written the code in the form_current event thinking that since the rowsource of cboRCMTask Options has to change on selection of value from cboRCMTask.
3.I am changing the rowsource of cboRCMTaskOptions in the afterupdate event of cboRCMTask

This was how I thought,there could be a better way of doing this.Please let me know if I'm mistaken.
Apr 20 '12 #3

P: 99
Isn't there any soultion to this?
Apr 23 '12 #4

Expert 100+
P: 634
Hi again

My only other thought is this
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboRCMTask_AfterUpdate() 
  2.     Me.cboRCMTaskOptions.RowSource = "SELECT ID, RCMTaskOptions FROM tblRCMTaskOptions WHERE RCM_ID=" & Me.cboRCMTask.Column(0) & " Or  RCM_ID=" & Me.RCM_ID & ";" 
  3.     Me.cboRCMTaskOptions = Me.cboRCMTaskOptions.ItemData(0) 
  4.     Me.cboRCMTaskOptions.Requery 
  5. End Sub 
ie I has added
Or RCM_ID=" & Me.RCM_ID & "
to the where condition which will guarantee that the current record value is available for display irrespective of the combobox selection.

Don't know if that helps!

MTB
Apr 23 '12 #5

P: 99
That didn't work. :(
Apr 26 '12 #6

Rabbit
Expert Mod 10K+
P: 12,324
Did you set the limit to list to no? If it's set to yes, the data in the other records won't show because it's not on the list. You need to set it to no.
Apr 26 '12 #7

P: 99
I tried setting Limit to list property to NO but it seems to be not working.
May 15 '12 #8

Rabbit
Expert Mod 10K+
P: 12,324
I'm out of ideas, the only thing left is for you to attach the database so we can look at it.
May 15 '12 #9

Post your reply

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