?
Solved

Access 2007 - Filter Combo Box options

Posted on 2011-02-18
8
Medium Priority
?
404 Views
Last Modified: 2012-05-11
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
Comment
Question by:JosephEricDavis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34928839
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
 
LVL 7

Author Comment

by:JosephEricDavis
ID: 34928893
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
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 34928936
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Author Comment

by:JosephEricDavis
ID: 34929237
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
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 2000 total points
ID: 34929288
<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
 
LVL 7

Author Comment

by:JosephEricDavis
ID: 34929559
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34929735
JosephEricDa…,

please, one question per thread
0
 
LVL 7

Author Comment

by:JosephEricDavis
ID: 34929762
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question