filter combobox in sub form by field in main form

D

deb

I have a main form called fExtraHours - Fields are PMID and DateID

I want to filter a combo box (ProjID) in the subform(fExtraHoursSub) by the
PMID.

I want the combo box (ProjID) to only list the projects associated with the
PMID in the main form.

Please help
 
C

C Hayes

add a combo box linked to your pmid field

make the rowsource a sql statement:

SELECT tblProj.PMID, tblProj.ProjID FROM tblProj WHERE
(((tblProj.PMID)=[Forms]![Form1]![PMID]));
 
C

C Hayes

SELECT tblProj.PMID, tblProj.ProjID FROM tblProj WHERE
(((tblProj.PMID)=Forms!fpmid!PMID));


sql was wrong. sorry
 
C

C Hayes

First, I'm assuming a lot here.

change 'tblProj' to the name of the table that these fields reside.

SELECT tblProj.PMID, tblProj.ProjID FROM tblProj WHERE
(((tblProj.PMID)=Forms!fExtraHours!PMID));

I hope that works. Sorry for the confusion.
 
D

deb

This works initially.
but when I change to a different PMID, the subform combobox still has the
previous records that pertain to the previous PMID. It doesnt seem to update
when the PMID is changed.

Help!
 
C

C Hayes

help me out here.

you have a main form with two fields

pmID
dateID

you have a subform based off of , I assume, a related table with this field

projID

so you have a table that has records like

pmID projID
1 5
1 6
2 7
1 8
2 9

so when in the sub form your combo box only shows the projID with the same
pmID
you have to filter the combo based off of the main form's pmID

this is a parameter query that filters your combobox based off of the form's
pmID and should update on each record,

SELECT tblProj.PMID, tblProj.ProjID FROM tblProj WHERE
(((tblProj.PMID)=Forms!fExtraHours!PMID));

if you open a new record that present's a new situation
 

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