Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

697 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