Cascading Combo Box Problem

Varun

New member
Local time
Tomorrow, 09:28
Joined
May 8, 2008
Messages
4
Hi All,

I am a beginner at Access and am having a strange problem with cascading comboboxes

I have 2 combo boxes (referencing the same table 'MasterTable')

I want the contents of 1 combobox (named 'FieldCombo') to vary depending on the selection I make to the other (named 'TableCombo')

I have done the following till now:
In the AfterUpdate() of TableCombo:

Private Sub TableCombo_AfterUpdate()

Dim fieldSource As String

fieldSource = "Select t_fields from MasterList where t_name =" & Forms!
MainForm!TableCombo.Value
Me.FieldCombo.RowSource = fieldSource
Me.FieldCombo.RowSourceType = "Table/Query"
Me.FieldCombo.BoundColumn = 1

End Sub

In the Enter() of FieldCombo

Private Sub FieldCombo_Enter()
Me.FieldCombo.Requery
End Sub

My problem is that once I make a selection in TableCombo and click on FieldCombo, I get a popup asking me the following:

Enter a Parameter value:

I then have to re-enter the value I just selected from TableCombo again

I dont want this to appear and want the contents of FieldCombo to be AutoPopulated.

Any help is greatly appreaciated
 
Last edited:
If the RowSource of the FieldCombo were:
"Select t_fields from MasterList where t_name = '" & Me.TableCombo & "'"
...then all you would need in the AfterUpdate event of the TableCombo is:
Me.FieldCombo.Requery
...and you could toss all of the other code.
 
Error Message Thrown

If the RowSource of the FieldCombo were:
"Select t_fields from MasterList where t_name = '" & Me.TableCombo & "'"
...then all you would need in the AfterUpdate event of the TableCombo is:
Me.FieldCombo.Requery
...and you could toss all of the other code.

Thanks RG but when I try the same it gives me this error
The record source 'sq_cMainForm~sq_cFieldCombo' specified on this form or report does not exist.

I have copied and pasted the query you wrote as is in the RowCommand Field of FieldCombo, and have now only the requery FieldCombo line in the AfterUpdate() of TableCombo.

Thanks once again

Regards
 
I have no idea where that error is coming from. Want to post your db so we can look at it? Remove any sensitive data of course.
 
I have no idea where that error is coming from. Want to post your db so we can look at it? Remove any sensitive data of course.

As of right now it contains only 1 table called 'MasterList'
The table has 3 columns

ID PK
t_name text
t_fields text

Thanks for taking time out
 
Do a Compact and Repair and then zip it up and post it so we can look at it.
 

Users who are viewing this thread

Back
Top Bottom