[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Access 2007 - Filter Combo Box options

I've got a form that is bound to a source that basically represents one record at a time with primary key being ProjectID.  Inside this form I have a combo box that allows me to select different projects.  I've got code written that automatically will update the record the form is bound to based on the selection of the projectID combo box.

Also in this form I have a sub form that is a continuous form and shows a listing of records.  One of the fields in this form is bound by a combo box having a row source built with quite a few options.  I need this list of options to be filtered by the project that is selected in the parent form.  I have the Link Master Field and the Link Child Field both set to ProjectID, I'm just not sure how to utilize that projectID to impose a filter on the combo box in the sub form.

If I need to say anything else to provide further clarification just let me know.

Thanks
0
JosephEricDavis
Asked:
JosephEricDavis
  • 4
  • 4
2 Solutions
 
Rey Obrero (Capricorn1)Commented:
you just need to set the rowsource of the combo box with a criteria that points to the ProjectID,


what is the rowsource of the combo?


0
 
JosephEricDavisAuthor Commented:
SELECT tbContractProject.ContractID, tbContract.Name FROM tbContract INNER JOIN tbContractProject ON tbContract.ContractID=tbContractProject.ContractID;

tbContractProject has a field, ProjectID, which is what I need to filter on.  Filter by the parent form ProjectID.
0
 
Rey Obrero (Capricorn1)Commented:
Add the field ProjectID to the RowSource


SELECT tbContractProject.ContractID, tbContract.Name, tbContractProject.ProjectID FROM tbContract INNER JOIN tbContractProject ON tbContract.ContractID=tbContractProject.ContractID
Where tbContractProject.ProjectID =Forms!NameOfParentForm!ProjectID

set the column count of the combo box to 3
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
JosephEricDavisAuthor Commented:
It doesn't seem to be working when I set it this way in the row source directly in the properties window like this.

I can do it in code like this however...

Form_ExpenditureLedger.ddlContractProjectID.RowSource = "SELECT tbContractProject.ContractID, tbContract.Name FROM tbContract INNER JOIN tbContractProject ON tbContract.ContractID=tbContractProject.ContractID WHERE tbContractProject.ProjectID = Forms!frmExpenditure!ProjectID"

But I would rather not have to do it that way if I can avoid it.
0
 
Rey Obrero (Capricorn1)Commented:
<It doesn't seem to be working> why,
did you select a project form the combo box in the main form?

in this line

Forms!frmExpenditure!ProjectID   < ProjectID is a Combo box.. if it is , change name to cboProjectID

in the afterUpdate of cboProjectID

private sub cboProjectID_afterupdate()

Form_ExpenditureLedger.ddlContractProjectID.Requery

end sub
0
 
JosephEricDavisAuthor Commented:
Actually, ok that will work fine.

But the next related problem is that I have a second combo box in the same row as the one previously in question.  The options available in this second combo box need to be set based on the value selected in the first.

This is an interesting problem because if I try to do it like I've done with the other one above, in code, then it will reset the values for all the combo boxes on the form, not just for the row the user is working on.

I need to have some way where I can filter the values in this second combo box based on the values selected in the first combo box on a row by row basis.
0
 
Rey Obrero (Capricorn1)Commented:
JosephEricDa…,

please, one question per thread
0
 
JosephEricDavisAuthor Commented:
ok... sorry.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now