Solved

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

Posted on 2007-12-04
3
376 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

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

9 Experts available now in Live!

Get 1:1 Help Now