linked combo boxes

  • Thread starter Thread starter o wilson
  • Start date Start date
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
 
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
 
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
 
Back
Top