Multiple Table Combo Box form Query

G

Guest

Hello all. Thanks for any help in advance. I will cut most of what i have
down to a few fields that can be worked off.

I have 3 tables:

tblAction with a field "action"
tblInfo with a field "lastname"

I have a form named "Form1" which has 2 combo boxes and a button

combo1 named "cbxlastname" pulls its data from tblInfo lastname field
combo2 named "cbxaction" pulls its data from tblAction action field
button named btnQuery runs the query which will eventually print a report,
for now I cant get the query to work.

Basically I want the Query to run with whatever are in the combo boxes on
Form1. It will work when its blank, it will work with the cbxaction(combo2)
information, however it will not pull from the cbxlastname(combo1)
information. It will also not pull if both combo boxes are filled with
information. It will however, pull if there is no information in them.

here is the SQL for the Query:

SELECT tblPerson_Info.last, tblPerson_Action.action
FROM tblPerson_Action INNER JOIN tblPerson_Info ON tblPerson_Action.last =
tblPerson_Info.last
WHERE (((tblPerson_Info.last)=[Forms]![Form1]![lastname]) AND
((tblPerson_Action.action)=[Forms]![Form1]![action])) OR
(((tblPerson_Action.action)=[Forms]![Form1]![action]) AND
(([Forms]![Form1]![lastname]) Is Null)) OR
(((tblPerson_Info.last)=[Forms]![Form1]![lastname]) AND
(([Forms]![Form1]![action]) Is Null)) OR ((([Forms]![Form1]![lastname]) Is
Null) AND (([Forms]![Form1]![action]) Is Null));

Relationships are set up for the lastname fields in both tables. This is
the common field in both. The primary Key is the ID field.

What am I doing wrong? Dont get too crazy with me, I learn best by example.
Thanks again!
 
G

Guest

I belive I have solved the problem. I used the formula below in each of the
fields i put in my query, from whatever table I want

Like [Forms]![FormWithCombos]![ComboFieldName] & "*"

Which seems to work from multiple tables just fine, pulling whatever is in
the combo box, in either box, full or empty.

I also removed the ID Primary key fields in both tables and replaced them
with "employee_number". Although I only used the tblInfo as the primary key.

Also the tblAction employee_number field is a lookup field pulling from
tblInfo employee_number
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top