Solved

Too many results for query

Posted on 2011-09-09
7
247 Views
Last Modified: 2012-06-21
Morning,

I have the following error and could not find any resources to help me here or in internet

I am running a query which will sort a column of combinations and related fields based on user entered values. Since I did not know any other ways, I went in to query design view and in the criteria (of the combination column) put in the following

(GetO([Forms]![Point2Point]![ocitytxt] & [Forms]![Point2Point]![oprovcombo])) & (GetO([Forms]![Point2Point]![dcitytxt] & [Forms]![Point2Point]![dprovcombo]))

Open in new window


GetO is a function and rest are user entered fields. I've done a self test on the fields and they are populating fine. The problem is, when I run the query, instead of populating nearly 17 records (based on combination), its populating 94,000 rows and related data

The combination is same but its duplicating the data on the output of query!

Anyone know any common source of this? Any help is much appreciated as this is blocking me from proceeding :/

Thanks!

0
Comment
Question by:Shanan212
[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
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36510555
did you use Group By in your query ?

0
 
LVL 77

Expert Comment

by:peter57r
ID: 36510559
Please post the sql view of your query
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 36510607
It would also be useful to know either what the Get0() function code looks like, or what the function returns for a couple of values.
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 13

Author Comment

by:Shanan212
ID: 36510647
SQL of query

SELECT INTER.TCOMBI, INTER.LTL, INTER.[500], INTER.[1M], INTER.[2M], INTER.[5M], INTER.[10M], INTER.[20M] INTO BTER
FROM OUT, INTER
WHERE (((INTER.TCOMBI)=(GetO([Forms]![Point2Point]![ocitytxt] & [Forms]![Point2Point]![oprovcombo])) & (GetO([Forms]![Point2Point]![dcitytxt] & [Forms]![Point2Point]![dprovcombo]))));

Open in new window


Only 1 column is filtered using function above

GetO function is in Module1 - Returns a combination based on 4 user entered values. Again, this part is working as the query is actually sorting but somehow bringing in way too many duplicates instead of 17.

Function GetO(origin As String) As String

        Dim rst As DAO.Recordset
        Dim strSQL As String
        Dim varResult As String
        
        strSQL = "Select OUT.TCOMBI " & "FROM OUT " & "WHERE OUT.OUTCOMBI = '" & origin & "' " '& "ORDER BY tblAll.City;"
        Set rst = CurrentDb.OpenRecordset(strSQL)
        
        If Not (rst.EOF And rst.BOF) Then
            GetO = DLookup("TCOMBI", "OUT")
        End If
        
        Set rst = Nothing
        
End Function

Open in new window

0
 
LVL 22

Accepted Solution

by:
Thomasian earned 500 total points
ID: 36510730
Including OUT table on the query causes a cross join between the 2 tables, thus it is returning duplicates. Exclude it from the query since the record is retrieved inside the function
SELECT INTER.TCOMBI, INTER.LTL, INTER.[500], INTER.[1M], INTER.[2M], INTER.[5M], INTER.[10M], INTER.[20M] INTO BTER
FROM INTER
WHERE (((INTER.TCOMBI)=(GetO([Forms]![Point2Point]![ocitytxt] & [Forms]![Point2Point]![oprovcombo])) & (GetO([Forms]![Point2Point]![dcitytxt] & [Forms]![Point2Point]![dprovcombo]))));

Open in new window

0
 
LVL 13

Author Comment

by:Shanan212
ID: 36510771
Wow! Its a matter of having that table opened in the design view eh!
I removed that table and it worked like a charm :)
Thanks a ton!
0
 
LVL 13

Author Closing Comment

by:Shanan212
ID: 36510776
Thank you for an eye-opening lesson!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

623 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