Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Too many results for query

Posted on 2011-09-09
7
Medium Priority
?
260 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
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 49

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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…
Suggested Courses

972 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