Results 1 to 10 of 10
  1. #1
    karl1971 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    8

    Query Works until add criteria. after which it returns same record a thousand times.


    This must be simple to someone. When I run my query.. say.. Name, State, Zip.. it returns fine. But when I try to just see LA as state, or APPROVED as status.. it returns the first event event.. and populates a huge table with the same record. Just the addition of ="LA" glitches it.. I would expect it to just pull the records where the state is LA. What am I doing wrong? BTW I am running 2007 Guess I am in the wrong Forum.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What is the SQL of the query?

  3. #3
    karl1971 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    8
    SELECT qryZipCodeCat.CARR_ID, qryZipCodeCat.STATE, qryZipCodeCat.zipcode, PIDFSR1_US_ZIPS.LAT, PIDFSR1_US_ZIPS.LON
    FROM qryZipCodeCat INNER JOIN PIDFSR1_US_ZIPS ON qryZipCodeCat.zipcode=PIDFSR1_US_ZIPS.ZIP;

    I had to concatenate the zip (which was split into two fields) Which I saved as qryZipCodeCat. Then I ran that against my Zip code table with all city zipcodes/lat longs. It works for the first instance and repeats it ad infinitum I suppose

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I see nothing wrong with the SQL.

    When you tried to filter by State, is this what the SQL looked like?
    Code:
    SELECT qryZipCodeCat.CARR_ID, qryZipCodeCat.STATE, qryZipCodeCat.zipcode, PIDFSR1_US_ZIPS.LAT, PIDFSR1_US_ZIPS.LON
    FROM qryZipCodeCat INNER JOIN PIDFSR1_US_ZIPS ON qryZipCodeCat.zipcode=PIDFSR1_US_ZIPS.ZIP
    WHERE qryZipCodeCat.STATE = "LA";

    What is the SQL for qryZipCodeCat?

  5. #5
    karl1971 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    8
    SELECT ICQ_CARRIERS.CARR_ID, [pst_1_c] & "" & [pst_2_c] AS zipcode, ICQ_CARRIERS.STATE
    FROM PIDFSR1_US_ZIPS, ICQ_CARRIERS
    WHERE (((ICQ_CARRIERS.STATE)="LA"));


    Here is the query that I would Filter by state.. I just did it, and got one record over and over and over.. not useful really
    CARR_ID zipcode STATE
    AANC 70737 LA

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try adding DISTINCT :
    Code:
    SELECT DISTINCT ICQ_CARRIERS.CARR_ID, [pst_1_c] & "" & [pst_2_c] AS zipcode, ICQ_CARRIERS.STATE
    FROM PIDFSR1_US_ZIPS, ICQ_CARRIERS
    WHERE (((ICQ_CARRIERS.STATE)="LA"));


    The empty string is not needed between [pst_1_c] and [pst_2_c].
    Code:
    SELECT DISTINCT ICQ_CARRIERS.CARR_ID, [pst_1_c] & [pst_2_c] AS zipcode, ICQ_CARRIERS.STATE
    FROM PIDFSR1_US_ZIPS, ICQ_CARRIERS
    WHERE (((ICQ_CARRIERS.STATE)="LA"));
    Why is there [pst_1_c] and [pst_2_c]? What does the data look like? (Just curoius)

  7. #7
    karl1971 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    8
    for some reason (I am trying to find out why) this company has broken the zip code into two fields. Which I can't use. It looks like: DesMoines 503 09
    which is the city, first 3 of the zip, then last 2 of zip in three separate fields. There must be a reason. Cool, I will try that distinct trick.. I am still learning

  8. #8
    karl1971 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    8
    well, I added the distinct clause.. and ran query.. and it appears to be crunching data.. which is an improvement. Unless it never stops.lol. let me say That I do appreciate your help in this matter.

  9. #9
    karl1971 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    8
    IT WORKED!!!!! Thank you x 100

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You're welcome.

    Ready to mark this solved?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 06-15-2014, 07:36 PM
  2. Replies: 7
    Last Post: 12-31-2013, 04:50 PM
  3. Replies: 2
    Last Post: 09-04-2012, 03:26 PM
  4. Replies: 6
    Last Post: 01-07-2011, 12:50 PM
  5. Replies: 3
    Last Post: 08-24-2010, 07:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums