473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Query showing repeats of the same record

43
Hi All,

I have created a query with 6 related tables as the record source.

The query includes 4 fields from 4 of the tables:

tblTourBookings
TourStartDate

tblAdditionalCosts
Price

tblCostDetails
Quantity

tblToursOffered
DayPrice

there is another field in the query which I made up:
Total Price: [DayPrice]+([Price]*[Quantity])

The problem occurs when I run the query, the same date can appear up to 4 times (even when I use the TourID primary key in the query, it is just repeated).

i have a perameter query under tourstartdate :

Between [Please enter Start Date] And [Please enter End Date]

This works correctly when the query is run.

Any help on why this may be occuring is greatly appreciated.

Many thanks in advance

best wishes

Edd
Apr 18 '07 #1
6 4314
pks00
280 Expert 100+
Can u post your query?

u may get away with using DISTINCT or u might need a inner query
Apr 18 '07 #2
xian2
43
Hi, the query is:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblTourBookings.TourStartDate, tblAdditionalCosts.Price, tblCostDetails.Quantity, tblToursOffered.DayPrice, [DayPrice]+([Price]*[Quantity]) AS [Total Price]
  2. FROM tblToursOffered INNER JOIN ((tblClient INNER JOIN (tblAdditionalCosts INNER JOIN (tblTourBookings INNER JOIN tblCostDetails ON tblTourBookings.TourID = tblCostDetails.TourID) ON (tblAdditionalCosts.AdittionalCostID = tblCostDetails.AdditionalCostID) AND (tblAdditionalCosts.AdittionalCostID = tblCostDetails.AdditionalCostID)) ON (tblClient.[Client ID] = tblTourBookings.ClientID) AND (tblClient.[Client ID] = tblTourBookings.ClientID)) INNER JOIN tblTourDetails ON tblTourBookings.TourID = tblTourDetails.TourID) ON (tblToursOffered.ToursOfferedID = tblTourDetails.ToursOfferedID) AND (tblToursOffered.ToursOfferedID = tblTourDetails.ToursOfferedID)
  3. WHERE (((tblTourBookings.TourStartDate) Between [Please enter Start Date] And [Please enter End Date]));

Many thanks for your response

Edd
Apr 18 '07 #3
xian2
43
That code is very long so I thought I would post it as text as well to make it easier to read (well maybe, depending on how you like things)

SELECT tblTourBookings.TourStartDate, tblAdditionalCosts.Price, tblCostDetails.Quantity, tblToursOffered.DayPrice, [DayPrice]+([Price]*[Quantity]) AS [Total Price]
FROM tblToursOffered INNER JOIN ((tblClient INNER JOIN (tblAdditionalCosts INNER JOIN (tblTourBookings INNER JOIN tblCostDetails ON tblTourBookings.TourID = tblCostDetails.TourID) ON (tblAdditionalCosts.AdittionalCostID = tblCostDetails.AdditionalCostID) AND (tblAdditionalCosts.AdittionalCostID = tblCostDetails.AdditionalCostID)) ON (tblClient.[Client ID] = tblTourBookings.ClientID) AND (tblClient.[Client ID] = tblTourBookings.ClientID)) INNER JOIN tblTourDetails ON tblTourBookings.TourID = tblTourDetails.TourID) ON (tblToursOffered.ToursOfferedID = tblTourDetails.ToursOfferedID) AND (tblToursOffered.ToursOfferedID = tblTourDetails.ToursOfferedID)
WHERE (((tblTourBookings.TourStartDate) Between [Please enter Start Date] And [Please enter End Date]));

Thanks again

Edd
Apr 18 '07 #4
pks00
280 Expert 100+
Is the price, quantity and dayprice the same for each tourdate?

do u get the desired results if u place a distinct?

i.e..

SELECT DISTINCT tblTourBookings.TourStartDate
Apr 18 '07 #5
xian2
43
Is the price, quantity and dayprice the same for each tourdate?

do u get the desired results if u place a distinct?

i.e..

SELECT DISTINCT tblTourBookings.TourStartDate

Hi,

Many thanks for your reply.

The DISTINCT bit helped and the price and quantity are the additional costs like ferry crossings which there could be 2 of. Whereas the dayprice is for the tour for which each day can only be put once.

The DISTINCT query sorted it down to only two rows, one for the Dayprice and one for the additional costs. The only problem is that each row has the same total.

i think I may need to make two queries and build them as subforms into a report.

Any other suggestions are very welcome

Best

Edd
Apr 19 '07 #6
NeoPa
32,556 Expert Mod 16PB
DISTINCTROW will lose multiple items that already exist inside a table.
Properly linking the tables together will mean that multiple items are not re-shown.

You need to consider this carefully.
Apr 20 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: jason | last post by:
I could sure use some conceptualization and query help with a Page Watch System I am building in Access 2000 and Asp. I need to cycle through databae and generate a compiliation query email that...
3
by: I_was_here | last post by:
Hey if anyone is a query pro please showoff some knowledge thx. Ie: I have a table with : part price location qty 1 part repeats throughout the table and its price remains the same but it...
5
by: Sean Byrne | last post by:
We have a Microsoft Access 2000 database consisting of 20 tables covering 20 different events. In each table, there are 3 Team members, a date of the event and several unique fields for the event,...
4
by: Maxi | last post by:
I have posted my question on my website as the alignment in this post goes for a toss. The text editor wraps up the data in the next line by default and because of which I am not able to copy my...
13
by: Maxi | last post by:
I have a table (Table name : Lotto) with 23 fields (D_No, DrawDate, P1, P2,.....P21) and it has draw results from 1st Sep 2004 till date. I have another table (Table name : Check) with 15 fields...
0
by: ET | last post by:
We have two tables... one with primary key ID and second table with secondary key to the ID in the first table... Now, they query pulls records from both tables, looks like this: SELECT...
2
by: Thomas | last post by:
Hi All. I think that if I explain the database layout first it may be easier to ask my question. Table Name Field Name Test TestCode Description SpecimenRequirements FeeSchedule TestCode...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
1
by: jglabas | last post by:
For a report, I am using a query as my record source. The query produces 5 columns by 3272 records. The data in columns 1 & 2 (“Objective” and “Rating”) repeats every 409 records The data for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.