Cascading Comboboxes

G

Guest

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"
 
G

Guest

I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

xRoachx said:
In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




RTimberlake said:
I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

RTimberlake said:
I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

xRoachx said:
In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




RTimberlake said:
I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

No problem. I am sure that my post was as clear as mud.
Here is what I am trying to do...
I have a very large database that I am attempting to create. I have 1 form
that all of the data will be entered on. Within this main form I have various
subforms and tables. When I created the form for Charges and put int he
codes, everything worked beautifully. When I placed that form on my main form
(as a subform) the combobox would no longer pull the information that I
needed. It threw up a box that said "Enter Parameter for
=tables!stblCharges.Category.
I am baffled. The form works fine on its own, but will not work as a subform.
As as result of these problems, I decided to use a subtable instead.
However, I cannot get the fomulas to work there either.
I am getting extremely frustrated with this program.

xRoachx said:
Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

RTimberlake said:
I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

xRoachx said:
In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




:

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

Ok, I get it now. Sorry for the confusion.

Since the second combo box is in the subform, you need to reference it
differently. Have you tried this:

Dim strValue as String

strValue = cboONE.Value

Forms![MAIN FORM NAME]![SUBFORM NAME].cboSECOND.RowSource = "Select
tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"

RTimberlake said:
No problem. I am sure that my post was as clear as mud.
Here is what I am trying to do...
I have a very large database that I am attempting to create. I have 1 form
that all of the data will be entered on. Within this main form I have various
subforms and tables. When I created the form for Charges and put int he
codes, everything worked beautifully. When I placed that form on my main form
(as a subform) the combobox would no longer pull the information that I
needed. It threw up a box that said "Enter Parameter for
=tables!stblCharges.Category.
I am baffled. The form works fine on its own, but will not work as a subform.
As as result of these problems, I decided to use a subtable instead.
However, I cannot get the fomulas to work there either.
I am getting extremely frustrated with this program.

xRoachx said:
Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

RTimberlake said:
I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

:

In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




:

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

When I tried that it gives me a "Compile Error: Expected end of statement"
How can I fix that.

I put this in the After Update Event.


Private Sub cmbLegal_AfterUpdate()
Dim strValue As String

strValue = cmbCategory.Value

Dim strValue As String

strValue = cboONE.Value

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "
tblCharges.Legal " & _"FROM tblCharges" & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"


End Sub
xRoachx said:
Ok, I get it now. Sorry for the confusion.

Since the second combo box is in the subform, you need to reference it
differently. Have you tried this:

Dim strValue as String

strValue = cboONE.Value

Forms![MAIN FORM NAME]![SUBFORM NAME].cboSECOND.RowSource = "Select
tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"

RTimberlake said:
No problem. I am sure that my post was as clear as mud.
Here is what I am trying to do...
I have a very large database that I am attempting to create. I have 1 form
that all of the data will be entered on. Within this main form I have various
subforms and tables. When I created the form for Charges and put int he
codes, everything worked beautifully. When I placed that form on my main form
(as a subform) the combobox would no longer pull the information that I
needed. It threw up a box that said "Enter Parameter for
=tables!stblCharges.Category.
I am baffled. The form works fine on its own, but will not work as a subform.
As as result of these problems, I decided to use a subtable instead.
However, I cannot get the fomulas to work there either.
I am getting extremely frustrated with this program.

xRoachx said:
Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

:

I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

:

In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




:

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

At the end of this statement (after the quote)::

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "

You need to add

& _

So the statement reads like this:

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select " & _

You generally get that error message for incorrect syntax.

RTimberlake said:
When I tried that it gives me a "Compile Error: Expected end of statement"
How can I fix that.

I put this in the After Update Event.


Private Sub cmbLegal_AfterUpdate()
Dim strValue As String

strValue = cmbCategory.Value

Dim strValue As String

strValue = cboONE.Value

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "
tblCharges.Legal " & _"FROM tblCharges" & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"


End Sub
xRoachx said:
Ok, I get it now. Sorry for the confusion.

Since the second combo box is in the subform, you need to reference it
differently. Have you tried this:

Dim strValue as String

strValue = cboONE.Value

Forms![MAIN FORM NAME]![SUBFORM NAME].cboSECOND.RowSource = "Select
tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"

RTimberlake said:
No problem. I am sure that my post was as clear as mud.
Here is what I am trying to do...
I have a very large database that I am attempting to create. I have 1 form
that all of the data will be entered on. Within this main form I have various
subforms and tables. When I created the form for Charges and put int he
codes, everything worked beautifully. When I placed that form on my main form
(as a subform) the combobox would no longer pull the information that I
needed. It threw up a box that said "Enter Parameter for
=tables!stblCharges.Category.
I am baffled. The form works fine on its own, but will not work as a subform.
As as result of these problems, I decided to use a subtable instead.
However, I cannot get the fomulas to work there either.
I am getting extremely frustrated with this program.

:

Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

:

I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

:

In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




:

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

Thank you for all of your help. People like you make this program a lot less
frustrating.

xRoachx said:
At the end of this statement (after the quote)::

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "

You need to add

& _

So the statement reads like this:

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select " & _

You generally get that error message for incorrect syntax.

RTimberlake said:
When I tried that it gives me a "Compile Error: Expected end of statement"
How can I fix that.

I put this in the After Update Event.


Private Sub cmbLegal_AfterUpdate()
Dim strValue As String

strValue = cmbCategory.Value

Dim strValue As String

strValue = cboONE.Value

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "
tblCharges.Legal " & _"FROM tblCharges" & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"


End Sub
xRoachx said:
Ok, I get it now. Sorry for the confusion.

Since the second combo box is in the subform, you need to reference it
differently. Have you tried this:

Dim strValue as String

strValue = cboONE.Value

Forms![MAIN FORM NAME]![SUBFORM NAME].cboSECOND.RowSource = "Select
tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"

:

No problem. I am sure that my post was as clear as mud.
Here is what I am trying to do...
I have a very large database that I am attempting to create. I have 1 form
that all of the data will be entered on. Within this main form I have various
subforms and tables. When I created the form for Charges and put int he
codes, everything worked beautifully. When I placed that form on my main form
(as a subform) the combobox would no longer pull the information that I
needed. It threw up a box that said "Enter Parameter for
=tables!stblCharges.Category.
I am baffled. The form works fine on its own, but will not work as a subform.
As as result of these problems, I decided to use a subtable instead.
However, I cannot get the fomulas to work there either.
I am getting extremely frustrated with this program.

:

Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

:

I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

:

In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




:

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 
G

Guest

Thanks!

These forums have been a great learning resource for me. Most of things I
have learned over the years have been through the direction of this forum. I
can't say enough good things about it either. :)

RTimberlake said:
Thank you for all of your help. People like you make this program a lot less
frustrating.

xRoachx said:
At the end of this statement (after the quote)::

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "

You need to add

& _

So the statement reads like this:

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select " & _

You generally get that error message for incorrect syntax.

RTimberlake said:
When I tried that it gives me a "Compile Error: Expected end of statement"
How can I fix that.

I put this in the After Update Event.


Private Sub cmbLegal_AfterUpdate()
Dim strValue As String

strValue = cmbCategory.Value

Dim strValue As String

strValue = cboONE.Value

Forms![frmMain]![sfrmMaster].cmbLegal.RowSource = "Select "
tblCharges.Legal " & _"FROM tblCharges" & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"


End Sub
:

Ok, I get it now. Sorry for the confusion.

Since the second combo box is in the subform, you need to reference it
differently. Have you tried this:

Dim strValue as String

strValue = cboONE.Value

Forms![MAIN FORM NAME]![SUBFORM NAME].cboSECOND.RowSource = "Select
tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"

:

No problem. I am sure that my post was as clear as mud.
Here is what I am trying to do...
I have a very large database that I am attempting to create. I have 1 form
that all of the data will be entered on. Within this main form I have various
subforms and tables. When I created the form for Charges and put int he
codes, everything worked beautifully. When I placed that form on my main form
(as a subform) the combobox would no longer pull the information that I
needed. It threw up a box that said "Enter Parameter for
=tables!stblCharges.Category.
I am baffled. The form works fine on its own, but will not work as a subform.
As as result of these problems, I decided to use a subtable instead.
However, I cannot get the fomulas to work there either.
I am getting extremely frustrated with this program.

:

Sorry, I missed read your post, LOL!

Are you trying to capture the value from the second field? Now that I
reread your post, I'm not sure what you are trying to accomplish. Are your
fields in the table displayed as combo boxes instead of text boxes?

:

I understand how that works in a form. How can I make it work in a table?
There is not an After Update event in the table. Or I just can't find it.

:

In the first combobox, in the AfterUpdate event, you need to capture the the
selected value and update the row source of the second combobox based on this
value. For example:

Dim strValue as String

strValue = cboONE.Value

cboSECOND.RowSource = "Select tblCharges.Legal " & _
"FROM tblCharges " & _
"WHERE tblCharges.Category = '" & strValue & "' " & _
"ORDER BY tblCharges.Legal;"




:

I am trying to link two feilds in a table. I know how to do this in a form
but I can't figure out how that translates to the table.

There are two feilds:
ChargeCategory and Charges

I need the user to be able to choose a selection from the first feild and
then the selections in the second feild to be limited to those records
relating to the first choice.

Here is what I have tried thus far:
The table name is stblCharges.
The data for the combo boxes is being pulled from tblCharges.

Under Rowsource for the first feild this is what I have:
SELECT DISTINCT tblCharges.Category FROM tblCharges;

Under Rowsource for the second feild this is what I have:
SELECT tblCharges.Legal FROM tblCharges WHERE
(((tblCharges.Category)=[tables]![stblCharges].[Category])) GROUP BY
tblCharges.Legal ORDER BY tblCharges.Legal;


Please let me know what I need to change to make this work. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top