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

Getting a 3rd dependent combo box to work

P: 5
Hi there,

I'm having trouble getting my 3rd dependent combo box to work in Access 2003.

I have three dependent boxes named cbogroup, cbosection and cbofunction. Each one is dependent on the selection made in the previous box. All of these appear on one form called 'records subform'.

The information for each box is taken from a different table. The first from 'functional group' which has only 2 fields: 'group' and 'group code'. The second box is populated from table 'functional section' which also contains the field 'group code' and this information is used to filter the choices for the second box. This is the row source for cbosection:

SELECT [Functional Section].[Section Code], [Functional Section].Section, [Functional Section].[Group Code] FROM [Functional Section] WHERE ((([Functional Section].[Group Code])=[cbogroup])) ORDER BY [Functional Section].[Section Code];

This works fine. However, my 3rd box won't play ball. The information is taken from table 'functional list' which is linked to 'functional section' using the field 'section code'. I assumed you could use the same row source, i.e. :

SELECT [Functional List].Code, [Functional List].[Section Code], [Functional List].Function FROM [Functional List] WHERE (([Functional List].Code)=[cbosection])) ORDER BY [Functional List].Code;

But when I put the criteria =[cbosection] in, the box just comes up blank.

This is the code I have used:

Private Sub cbogroup_AfterUpdate()
Me.cbosection = Null
Me.cbosection.Requery
End Sub

Private Sub cbosection_AfterUpdate()
Me.cbofunction = Null
Me.cbofunction.Requery
End Sub

Private Sub Form_Current()
Me.cbosection.Requery
Me.cbofunction.Requery
End Sub


Any ideas on where I'm going wrong?

Thanks!
Jul 13 '07 #1
Share this Question
Share on Google+
8 Replies


puppydogbuddy
Expert 100+
P: 1,923
Hi there,

I'm having trouble getting my 3rd dependent combo box to work in Access 2003.

I have three dependent boxes named cbogroup, cbosection and cbofunction. Each one is dependent on the selection made in the previous box. All of these appear on one form called 'records subform'.

The information for each box is taken from a different table. The first from 'functional group' which has only 2 fields: 'group' and 'group code'. The second box is populated from table 'functional section' which also contains the field 'group code' and this information is used to filter the choices for the second box. This is the row source for cbosection:

SELECT [Functional Section].[Section Code], [Functional Section].Section, [Functional Section].[Group Code] FROM [Functional Section] WHERE ((([Functional Section].[Group Code])=[cbogroup])) ORDER BY [Functional Section].[Section Code];

This works fine. However, my 3rd box won't play ball. The information is taken from table 'functional list' which is linked to 'functional section' using the field 'section code'. I assumed you could use the same row source, i.e. :

SELECT [Functional List].Code, [Functional List].[Section Code], [Functional List].Function FROM [Functional List] WHERE (([Functional List].Code)=[cbosection])) ORDER BY [Functional List].Code;

But when I put the criteria =[cbosection] in, the box just comes up blank.

This is the code I have used:

Private Sub cbogroup_AfterUpdate()
Me.cbosection = Null
Me.cbosection.Requery
End Sub

Private Sub cbosection_AfterUpdate()
Me.cbofunction = Null
Me.cbofunction.Requery
End Sub

Private Sub Form_Current()
Me.cbosection.Requery
Me.cbofunction.Requery
End Sub


Any ideas on where I'm going wrong?

Thanks!
Try commenting out what you have in the current event and test. If that leaves something out of synch, then requery the main form>>>>>Me.Requery<<<<<to bring everything in synch.
Jul 13 '07 #2

P: 5
Try commenting out what you have in the current event and test. If that leaves something out of synch, then requery the main form>>>>>Me.Requery<<<<<to bring everything in synch.

I'm sorry, I don't know what you mean by 'commenting out'!??
Jul 13 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
I'm sorry, I don't know what you mean by 'commenting out'!??
Commenting out means place a single quote in the left margin to turn an executable statement into a non-executable comment as show below.

Private Sub Form_Current()
'Me.cbosection.Requery
'Me.cbofunction.Requery
End Sub

The above 2 requery statements will not be executed because they are commented out.
Jul 13 '07 #4

P: 5
Commenting out means place a single quote in the left margin to turn an executable statement into a non-executable comment as show below.

Private Sub Form_Current()
'Me.cbosection.Requery
'Me.cbofunction.Requery
End Sub

The above 2 requery statements will not be executed because they are commented out.
Thanks for your help on this. But no luck I'm afraid! Any other ideas?
Jul 13 '07 #5

P: 5
I'm not sure what I did, but I've somehow managed to solve the problem! Thanks for your help!

C
Jul 13 '07 #6

puppydogbuddy
Expert 100+
P: 1,923
I'm not sure what I did, but I've somehow managed to solve the problem! Thanks for your help!

C
Please post the code you have now, so that other newbies can see what the final working code looks like in comparison to your prior posts. Thanks.
Jul 13 '07 #7

P: 5
I don't think it was changing the code that solved the problem, I think it was down to a glitch with the relationship between my second and third tables.

I did have to tweek the code slightly so that when you change the first box, the third box becomes a blank again. It now reads:

Private Sub cbogroup_AfterUpdate()
Me.cbosection = Null
Me.cbofunction = Null
Me.cbosection.Requery
Me.cbofunction.Requery
End Sub

Private Sub cbosection_AfterUpdate()
Me.cbofunction = Null
Me.cbofunction.Requery
End Sub

Private Sub Form_Current()
Me.cbosection.Requery
Me.cbofunction.Requery
End Sub
Jul 13 '07 #8

puppydogbuddy
Expert 100+
P: 1,923
Thanks. This will give any interested party another idea of where to look for a possible cause for combo box problems.
Jul 13 '07 #9

Post your reply

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