Hello,
I've tried many ways to solve my problem but nothing works.
I have two tables:
Customer Table with CustID(PK), Last, First, Route
Meals Table with CustID(PK), MealType, MonAM, TueAM, WedAM and so on for the week
For example:
Customer Table:
001 John White 1(Route Number)
002 Mary Jones 2
003 Kim Lee 1
Meals:
001 Hot 1 1 2 1 (The number of meals for particular day MonAM, MonPM and so on)
001 Frozen 1 1 2 2
002 Hot 2 2 1 1
I need to create a report where it will display customers who need to recieve meals on particular day. But only display them once even if the customer has more than one meal type.
I have this:
SELECT [Customer].CustID, [Customer].Route, [Customer].Last, [Customer].First, [Meals].MonAM, [Meals].TueAM, [Meals].WedAM ....
FROM [Customer] INNER JOIN [Meals] ON [Customer].[CustID]=[Meals].[CustID]
WHERE ((([Customer].[Route])>0) And (([Meals].MonAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Monday"))
Or ((([Customer].[Rte No])>0) And (([Meals].TueAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Tuesday"))
Or ((([Customer].[Rte No])>0) And (([Meals].WedAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Wednesday"))
Or ((([Customer].[Rte No])>0) And (([Meals].ThurAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Thursday"))
Or ((([Customer].[Rte No])>0) And (([Meals].FriAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Friday"))
Or ((([Customer].[Rte No])>0) And (([Meals].SatAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Saturday"))
Or ((([Customer].[Rte No])>0) And (([Meals Count].SunAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Sunday"))
ORDER BY [Customer].Route, [Customer].Last, [Customer].First;
In the report it displays John White twice, because he has two mealtypes in meals table.
If I use DISTINCT it gives me the same result. Could someone please help me with this. What else can I use instead of distinct.
Thank you in advance
YK
I've tried many ways to solve my problem but nothing works.
I have two tables:
Customer Table with CustID(PK), Last, First, Route
Meals Table with CustID(PK), MealType, MonAM, TueAM, WedAM and so on for the week
For example:
Customer Table:
001 John White 1(Route Number)
002 Mary Jones 2
003 Kim Lee 1
Meals:
001 Hot 1 1 2 1 (The number of meals for particular day MonAM, MonPM and so on)
001 Frozen 1 1 2 2
002 Hot 2 2 1 1
I need to create a report where it will display customers who need to recieve meals on particular day. But only display them once even if the customer has more than one meal type.
I have this:
SELECT [Customer].CustID, [Customer].Route, [Customer].Last, [Customer].First, [Meals].MonAM, [Meals].TueAM, [Meals].WedAM ....
FROM [Customer] INNER JOIN [Meals] ON [Customer].[CustID]=[Meals].[CustID]
WHERE ((([Customer].[Route])>0) And (([Meals].MonAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Monday"))
Or ((([Customer].[Rte No])>0) And (([Meals].TueAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Tuesday"))
Or ((([Customer].[Rte No])>0) And (([Meals].WedAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Wednesday"))
Or ((([Customer].[Rte No])>0) And (([Meals].ThurAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Thursday"))
Or ((([Customer].[Rte No])>0) And (([Meals].FriAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Friday"))
Or ((([Customer].[Rte No])>0) And (([Meals].SatAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Saturday"))
Or ((([Customer].[Rte No])>0) And (([Meals Count].SunAM)>0) And ((Forms![Delivery AM Dialog]!dayOfWeek)="Sunday"))
ORDER BY [Customer].Route, [Customer].Last, [Customer].First;
In the report it displays John White twice, because he has two mealtypes in meals table.
If I use DISTINCT it gives me the same result. Could someone please help me with this. What else can I use instead of distinct.
Thank you in advance
YK