[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Access 2007 - Filter Combo Box options

Posted on 2011-02-18
8
Medium Priority
?
410 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
Independent Software Vendors: 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!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

656 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