?
Solved

Query help with WHERE statement

Posted on 2011-10-25
13
Medium Priority
?
234 Views
Last Modified: 2012-05-12
Experts,
Every store has differet types of employees assigned to it. My table tblAssignedStoreEmployees is designed to capture these employees:
DesignatedEmployeeID (Number)
StoreID (FK)
DistrictManager (FK)
StoreManager (FK)
I have three additional tables:
tblStore
StoreID (PK)

tblEmployee
EmployeeID (PK)

tblEmployeeType
EmployeeTypeID (PK)

I have struggled with this query listed below getting no where. My objective is to query the employee, e.g. DistrictManager and StoreManager associated with the store. This example only is looking for the District Manager but I get that solved I can do the store manager

DistrictManager: (Select [tblEmployee.EmployeeFirstName]
&" "&[tblEmployee.EmployeeLastName] AS DMName
FROM tblEmployee INNER JOIN 
tblAssignedStoreEmployees.DistrictManager 
Where tblAssignedStoreEmployees.StoreID
= tblStore.StorNumberID and 
tblEmployee.EmployeeID IN (1,5))

Open in new window

0
Comment
Question by:Frank Freese
  • 8
  • 4
13 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37027740
shouldn't you be using the table/field  
 tblEmployeeType.EmployeeTypeID  ?


0
 

Author Comment

by:Frank Freese
ID: 37027749
I think your right - let me try that now....
0
 

Author Comment

by:Frank Freese
ID: 37027777
I changed to this and received a syntax error:

DistrictManager: (Select [tblEmployee.EmployeeFirstName]
&" "&[tblEmployee.EmployeeLastName]
AS DMName FROM tblEmployee
INNER JOIN 
tblAssignedStoreEmployees.DistrictManager 
Where tblAssignedStoreEmployees.StoreID
= tblStore.StorNumberID and 
tblEmployeeType.EmployeeTypeID IN (1,5))

Open in new window

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37027786
post the whole query
0
 

Author Comment

by:Frank Freese
ID: 37027795
I found two errors - but still get syntex error
0
 
LVL 31

Expert Comment

by:hnasr
ID: 37027818
"INNER JOIN
tblAssignedStoreEmployees.DistrictManager " INNER JOIN table not a field!

INNER JOIN table ON field1=field2

Save time and effort of reproducing your database, by including a sample database. List the required output.

0
 

Author Comment

by:Frank Freese
ID: 37027864
I'm getting closer:
DistrictManager: (Select [tblEmployee.EmployeeFirstName]
&" "&[tblEmployee.EmployeeLastName] 
AS DMName FROM tblEmployee 
INNER JOIN tblAssignedStoreEmployees
ON tblEmployee.EmployeeID = 
tblAssignedStoreEmployees.DistrictManager 
Where tblAssignedStoreEmployees.StoreID
= tblStore.StoreID and 
tblEmployeeType.EmployeeTypeID IN (1,5))

Open in new window

But get an error at tblStore.StoreID
0
 

Author Comment

by:Frank Freese
ID: 37027879
error at = tblStore.StoreID which should have been
tblStore.StoreNumberID but still not there?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37027899
upload a copy of the db
0
 

Author Comment

by:Frank Freese
ID: 37027915
the attached db open to the form with the problem and the error.
StoreBonusRev2.mdb
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 37027977
test this


StoreBonusRev2.mdb
0
 

Author Comment

by:Frank Freese
ID: 37028044
I've confused things cap and I apologize for wasting your time . I'm wanting to list in that combo box just District Managers. All I needed to do was under employee type enter a 1 or 5.  
0
 

Author Closing Comment

by:Frank Freese
ID: 37028050
I thank you and again I'm sorry for wasting your time. Guess just tired..
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

809 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