Solved

Access 2007 - Filter Combo Box options

Posted on 2011-02-18
8
355 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
  • 4
  • 4
8 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
 
LVL 7

Author Comment

by:JosephEricDavis
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 500 total points
Comment Utility
<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
Comment Utility
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 119

Expert Comment

by:Rey Obrero
Comment Utility
JosephEricDa…,

please, one question per thread
0
 
LVL 7

Author Comment

by:JosephEricDavis
Comment Utility
ok... sorry.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now