T
Tom
I need to create data dependencies between combo boxes.
Let's say I have the following table hierarchy:
tblDivision (parent of tblSection)
tblSection (parent of tblBilletCode)
TABLES:
tblDivision contains the following field(s) and data:
Division
A
B
C
tblSections contains the following field(s) and data:
Division Sections
A AA
A AB
B BA
B BB
C CA
C CB
tblBilletCodes contains the following field(s) and data:
Division Sections BilletCode
A AA AAA
A AA AAB
A AA AAC
A AA AAD
A AA AAE
A AB ABA
A AB ABB
A AB ABC
B BA BAA
B BA BAB
B BA BAC
B BB BBA
C CA CAA
C CA CAB
C CB CBA
C CB CBB
C CB CBC
Currently, I have the 3 combos (Division, Sections, BilletCodes) on a single form.
QUERIES:
For queries, I use the following:
1. qryDivision:
SELECT tbl_NatoDivisions.Division FROM tbl_NatoDivisions ORDER BY tbl_NatoDivisions.Division;
2. qrySections:
SELECT tbl_NatoDivisionsSections.Sections FROM tbl_NatoDivisionsSections
WHERE (((tbl_NatoDivisionsSections.Division)=[Forms]![frmUpdateInfo]![Division]))
ORDER BY tbl_NatoDivisionsSections.Sections;
3. qryBilletCode:
SELECT tbl_NatoDivisionsSectionsBillets.BilletCode
FROM tbl_NatoDivisionsSectionsBillets
GROUP BY tbl_NatoDivisionsSectionsBillets.BilletCode, tbl_NatoDivisionsSectionsBillets.Sections
HAVING (((tbl_NatoDivisionsSectionsBillets.Sections)=[Forms]![frmUpdateInfo]![Sections]))
ORDER BY tbl_NatoDivisionsSectionsBillets.BilletCode;
4. qryUpdateInfo
SELECT tbl_UpdateInfo.Division, tbl_UpdateInfo.Sections, tbl_UpdateInfo.BilletCode
FROM tbl_UpdateInfo
ORDER BY tbl_UpdateInfo.Division, tbl_UpdateInfo.Sections DESC;
FORMS:
Again, in the form frmUpdatInfo, I have placed the 3 combo boxes.
For both the Division and Section combo box, I placed the following code in the AfterChange event handler:
&&&&&&&&&&&&&&
Private Sub Division_Change()
Dim Division As ComboBox, Sections As ComboBox, BilletCode As ComboBox
Set Division = Forms![frmUpdateInfo].[Division]
Set Sections = Forms![frmUpdateInfo].[Sections]
Set BilletCode = Forms![frmUpdateInfo].[BilletCode]
Echo False
Sections.Requery
Me.Sections = Me.Sections.ItemData(0)
BilletCode.Requery
Me.BilletCode = Me.BilletCode.ItemData(0)
Echo True
End Sub
Private Sub Sections_Change()
Dim Sections As ComboBox, BilletCode As ComboBox
Set Sections = Forms![frmUpdateInfo].[Sections]
Set BilletCode = Forms![frmUpdateInfo].[BilletCode]
Echo False
BilletCode.Requery
Me.BilletCode = Me.BilletCode.ItemData(0)
Echo True
End Sub
&&&&&&&&&&&&&&
Okay, here now is the problem:
1. In a different application, I have am using a main form (Division) plus a subform (Section) plus a sub-subform (BilletCode). At this time (maybe because of the multipe subform layers) this approach does NOT work any longer.
2. Overall, this approach (even on a single form) seems very complicated.
So, my questions are... first, is there is an easier and more efficient way to show only specific values in a combo box (based on the superior combo box values)? If yes, could someone please
provide me some detailed pointers how to re-structure the data dependencies?
Second, if my approach seems to be reasonable, what may I have done wrong with the translation from single form to multiple sub forms?
Any help is truly appreciated!!!
Thanks in advance,
Tom
Let's say I have the following table hierarchy:
tblDivision (parent of tblSection)
tblSection (parent of tblBilletCode)
TABLES:
tblDivision contains the following field(s) and data:
Division
A
B
C
tblSections contains the following field(s) and data:
Division Sections
A AA
A AB
B BA
B BB
C CA
C CB
tblBilletCodes contains the following field(s) and data:
Division Sections BilletCode
A AA AAA
A AA AAB
A AA AAC
A AA AAD
A AA AAE
A AB ABA
A AB ABB
A AB ABC
B BA BAA
B BA BAB
B BA BAC
B BB BBA
C CA CAA
C CA CAB
C CB CBA
C CB CBB
C CB CBC
Currently, I have the 3 combos (Division, Sections, BilletCodes) on a single form.
QUERIES:
For queries, I use the following:
1. qryDivision:
SELECT tbl_NatoDivisions.Division FROM tbl_NatoDivisions ORDER BY tbl_NatoDivisions.Division;
2. qrySections:
SELECT tbl_NatoDivisionsSections.Sections FROM tbl_NatoDivisionsSections
WHERE (((tbl_NatoDivisionsSections.Division)=[Forms]![frmUpdateInfo]![Division]))
ORDER BY tbl_NatoDivisionsSections.Sections;
3. qryBilletCode:
SELECT tbl_NatoDivisionsSectionsBillets.BilletCode
FROM tbl_NatoDivisionsSectionsBillets
GROUP BY tbl_NatoDivisionsSectionsBillets.BilletCode, tbl_NatoDivisionsSectionsBillets.Sections
HAVING (((tbl_NatoDivisionsSectionsBillets.Sections)=[Forms]![frmUpdateInfo]![Sections]))
ORDER BY tbl_NatoDivisionsSectionsBillets.BilletCode;
4. qryUpdateInfo
SELECT tbl_UpdateInfo.Division, tbl_UpdateInfo.Sections, tbl_UpdateInfo.BilletCode
FROM tbl_UpdateInfo
ORDER BY tbl_UpdateInfo.Division, tbl_UpdateInfo.Sections DESC;
FORMS:
Again, in the form frmUpdatInfo, I have placed the 3 combo boxes.
For both the Division and Section combo box, I placed the following code in the AfterChange event handler:
&&&&&&&&&&&&&&
Private Sub Division_Change()
Dim Division As ComboBox, Sections As ComboBox, BilletCode As ComboBox
Set Division = Forms![frmUpdateInfo].[Division]
Set Sections = Forms![frmUpdateInfo].[Sections]
Set BilletCode = Forms![frmUpdateInfo].[BilletCode]
Echo False
Sections.Requery
Me.Sections = Me.Sections.ItemData(0)
BilletCode.Requery
Me.BilletCode = Me.BilletCode.ItemData(0)
Echo True
End Sub
Private Sub Sections_Change()
Dim Sections As ComboBox, BilletCode As ComboBox
Set Sections = Forms![frmUpdateInfo].[Sections]
Set BilletCode = Forms![frmUpdateInfo].[BilletCode]
Echo False
BilletCode.Requery
Me.BilletCode = Me.BilletCode.ItemData(0)
Echo True
End Sub
&&&&&&&&&&&&&&
Okay, here now is the problem:
1. In a different application, I have am using a main form (Division) plus a subform (Section) plus a sub-subform (BilletCode). At this time (maybe because of the multipe subform layers) this approach does NOT work any longer.
2. Overall, this approach (even on a single form) seems very complicated.
So, my questions are... first, is there is an easier and more efficient way to show only specific values in a combo box (based on the superior combo box values)? If yes, could someone please
provide me some detailed pointers how to re-structure the data dependencies?
Second, if my approach seems to be reasonable, what may I have done wrong with the translation from single form to multiple sub forms?
Any help is truly appreciated!!!
Thanks in advance,
Tom