Solved

Where Clause in Access Table/Query select statement in combo box

Posted on 2007-12-04
3
377 Views
Last Modified: 2013-11-28
I have a search combo box on a form to pull a record from a table. I would like to select certain records  to pull into the combo box based on data (year and location) in the table.

1) I have a form where the user puts in the year and location.
2) then the user clicks on a button that opens a form. The year and location are transferring from the form in #1 to this form.
3) I have a combo box on this second form:
SELECT [tr_hip_no], [tr_name1], [tr_name2], [tr_na_num] FROM transactions WHERE sale_year=me.sale_year And sale_location=me.sale_location ORDER BY [tr_name1];

When I run the form ...it prompts for me.sale_year and me.sale_location.

I also tried: frmtransactions is the form this combox is located:
WHERE sale_year=[frmtransactions].form.sale_year And sale_location=[frmtransactions].form.sale_location  

Thanks...

Proffittware
0
Comment
Question by:proffittware
3 Comments
 
LVL 14

Expert Comment

by:ldunscombe
ID: 20406945
In your sql statement you need to refer to the "controls" on your first form. Ie the form where the user enters the year and location and this selection form must remain open when you open the second form.

Leigh
0
 
LVL 15

Accepted Solution

by:
JimFive earned 500 total points
ID: 20412099
WHERE sale_year=[frmtransactions].form.sale_year And sale_location=[frmtransactions].form.sale_location  

Should be
WHERE sale_year = Forms!frmtransactions!sale_year AND sale_location = Forms!frmtransactions!sale_location

--
JimFive
0
 

Author Comment

by:proffittware
ID: 20413031
Thanks for both of you responding.

I found the examples helpful JimFive...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

863 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

20 Experts available now in Live!

Get 1:1 Help Now