linked combo boxes

O

o wilson

Hello,

I asked this question a few days ago and recieved a
response from Kurt that I tried but it didn't work.
Kurt Suggested the following:

Add this to the After Update event of cboDiv:

Me.cboCostCode.Requery

Any other suggestions would be greatly appreciated

I have two tables, tblDivisions and tblCostCode.
tblDivisions has two columns - DivID and Divisions.
There are 18 divisions numbered 1-18.

tblCostCode has three columns - CostCodeID, Div and
CostCode. Each Division can have several different cost
codes.

I have a form called frmLinkedControls with two combo
boxes, cboDiv and cboCostCode. I'd like cboCostCode to
display only those cost codes that apply to the division
selected in cboDiv. Here is my SQL statement:

SELECT tblCostCode.Div, tblCostCode.CostCode
FROM tblCostCode
WHERE (((tblCostCode.Div)=[Forms]![frmLinkedControls]!
[cboDiv]))
ORDER BY tblCostCode.Div, tblCostCode.CostCode;

cboCostCode is always empty, what have I done wrong?

TIA

Owen
 
R

Rob Oldfield

Your SQL statement just isn't going to work on it's own. It needs to be a
piece of text and built that way. Try, in the afterupdate of the first
combo....

Me.MySecondCombo.RowSource="SELECT tblCostCode.Div, tblCostCode.CostCode "+
_
"FROM tblCostCode " + _
"WHERE (((tblCostCode.Div)="+cstr(me.cbodiv)+")) "+ _
"ORDER BY tblCostCode.Div, tblCostCode.CostCode;"

Not sure if you need a requery as well.

(That's assuming that me.cbodiv is numeric.... otherwise you'll need a
couple of 's as well)




o wilson said:
Hello,

I asked this question a few days ago and recieved a
response from Kurt that I tried but it didn't work.
Kurt Suggested the following:

Add this to the After Update event of cboDiv:

Me.cboCostCode.Requery

Any other suggestions would be greatly appreciated

I have two tables, tblDivisions and tblCostCode.
tblDivisions has two columns - DivID and Divisions.
There are 18 divisions numbered 1-18.

tblCostCode has three columns - CostCodeID, Div and
CostCode. Each Division can have several different cost
codes.

I have a form called frmLinkedControls with two combo
boxes, cboDiv and cboCostCode. I'd like cboCostCode to
display only those cost codes that apply to the division
selected in cboDiv. Here is my SQL statement:

SELECT tblCostCode.Div, tblCostCode.CostCode
FROM tblCostCode
WHERE (((tblCostCode.Div)=[Forms]![frmLinkedControls]!
[cboDiv]))
ORDER BY tblCostCode.Div, tblCostCode.CostCode;

cboCostCode is always empty, what have I done wrong?

TIA

Owen
 
G

Guest

That AfterUpdate event is needed, so something else is wrong.

Make sure the bound column of cboDiv is referring to DivID.
For example, the properties of cboDiv should look something like:

Row Source: SELECT tblDivisions.DivID, tblDivisions.Divisions
FROM tblDivisions;
Column Count: 2
Column Widths: 0";1"
Bound Column: 1

If the Bound Column was 2, cboCostCode would stay empty.

Kurt


o wilson said:
Hello,

I asked this question a few days ago and recieved a
response from Kurt that I tried but it didn't work.
Kurt Suggested the following:

Add this to the After Update event of cboDiv:

Me.cboCostCode.Requery

Any other suggestions would be greatly appreciated

I have two tables, tblDivisions and tblCostCode.
tblDivisions has two columns - DivID and Divisions.
There are 18 divisions numbered 1-18.

tblCostCode has three columns - CostCodeID, Div and
CostCode. Each Division can have several different cost
codes.

I have a form called frmLinkedControls with two combo
boxes, cboDiv and cboCostCode. I'd like cboCostCode to
display only those cost codes that apply to the division
selected in cboDiv. Here is my SQL statement:

SELECT tblCostCode.Div, tblCostCode.CostCode
FROM tblCostCode
WHERE (((tblCostCode.Div)=[Forms]![frmLinkedControls]!
[cboDiv]))
ORDER BY tblCostCode.Div, tblCostCode.CostCode;

cboCostCode is always empty, what have I done wrong?

TIA

Owen
 

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

Similar Threads

Linked Combo Boxes 2
Linked Combos in a subform 1
Combo box help! 1
One more on linked combo boxes 1
combo box problem 2
Cascading Combo Boxes 1
Linked combo boxes 5
3 linked combo boxes in a form Options 37

Top