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

cascade combobox problem.

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
8 1795
MikeTheBike
639 Expert 512MB
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
HiGu
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
HiGu
99
Isn't there any soultion to this?
Apr 23 '12 #4
MikeTheBike
639 Expert 512MB
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
HiGu
99
That didn't work. :(
Apr 26 '12 #6
Rabbit
12,516 Expert Mod 8TB
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
HiGu
99
I tried setting Limit to list property to NO but it seems to be not working.
May 15 '12 #8
Rabbit
12,516 Expert Mod 8TB
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

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

Similar topics

1
by: jdk | last post by:
I have a main form where a students name is selected. After selected the name- the subform populates all criteria related to the students program. I have 2 combo boxes in the subform that...
1
by: jdk | last post by:
I have a main form where a students name is selected. After selected the name- the subform populates all criteria related to the students program. I have 3 combo boxes (Which choose a subject...
4
by: tonyblum | last post by:
Hi, I have a comboBox set to also be editable. If I have code that is something like: cmbBox.Text = "Hello"; MessageBox.Show(cmbBox.Text); The MessageBox will display just an empty string. I...
4
by: Martin Williams | last post by:
I have inserted a combobox into a datagrid cell. I am having difficulty getting the cell to retain the combobox selection. When I leave the cell, it remains empty. Here is the code, based on...
2
by: Lars Netzel | last post by:
I have a Combobox that is filled from a dataset. I want to let the user be able to edit the text in the Combobox and if he enters a text that is not a equal to any of the items in the combobox, I...
1
by: Lars Netzel | last post by:
Hi! In VB.NET want to draw my own items in a ComboBox I have added a ComboBox to the Form with this. -----------------------------------------------------------------------------------...
1
by: Frederik Vanderhaegen | last post by:
Hi, I'm trying change the layout of a combobox when f.e. a certain property is set to true. My problem is the following: when I execute the code, the combobox is repainted but there always...
1
by: amber | last post by:
I'm having an issue with a combobox that is making no sense to me at all. I have a form with several comboboxes/textboxes. The values in these boxes are based on a datarowview, which is based on...
1
by: massenza | last post by:
I have a combobox on my form. It is attached to a dataset and uses the values from datetimepicker's in the where clause. When the form opens, everything is retrieved correctly. When I change the...
1
Paks
by: Paks | last post by:
Hi there, I'm developing a web project based game and have run into a problem and gotten confused by the annotations in the Hibernate framework. I'm trying to have both the relation and child...
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...
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
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.