Results 1 to 11 of 11
  1. #1
    newbieaccess203 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    21

    EasyQuery having hard time

    Table Structure. To see more accurate table see the attachment:


    Region





    CountryCode





    CityCode





    Material





    RepNo





    RepRegion
    MIDSOUTH 106 458296 Iron 50002239 London Repository
    MIDSOUTH 106 458296 Iron 50085661 Spain Repository
    MIDSOUTH 106 608013 Iron 50002239 London Repository
    MIDSOUTH 106 608013 Iron 50085661 Spain Repository
    MIDSOUTH 106 950486 Iron 50002239 London Repository
    MIDSOUTH 106 950486 Iron 50085661 Spain Repository
    MIDSOUTH 111 458296 Iron 50002239 London Repository
    MIDSOUTH 111 458296 Iron 50085661 Spain Repository



    I am trying to write a query which will list the duplicate value of CountryCode and CityCode
    SELECT *
    FROM Table1 s2
    INNER JOIN Table1 s2


    ON (s2.CountryCode = s1.CountryCode AND
    s2.CityCode = s1.CityCode )
    WHERE s1.RepNo <> s2.RepNo ;

    this query ask me question to answer the city and country code.
    i do not want to enter the data.
    I want a query which will give me the listing from the table

    for example: from the attach table the result should be

    MIDSOUTH 106 458296 Iron 50002239 London Repository
    MIDSOUTH 106 458296 Iron 50085661 Spain Repository

    and than there should be next button, click which will take me to next dups record so for eg. if i click next it should show me:
    MIDSOUTH 106 608013 Iron 50002239 London Repository
    MIDSOUTH 106 608013 Iron 50085661 Spain Repository

    Clicking Next should show me:

    MIDSOUTH 106 950486 Iron 50002239 London Repository
    MIDSOUTH 106 950486 Iron 50085661 Spain Repository

    Clicking Next should show me:

    MIDSOUTH 111 458296 Iron 50002239 London Repository
    MIDSOUTH 111 458296 Iron 50085661 Spain Repository
    Attached Files Attached Files

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    SELECT *
      FROM Table1 s2
      INNER JOIN Table1 s2
        ON (s2.CountryCode = s1.CountryCode AND
            s2.CityCode = s1.CityCode )
      WHERE s1.RepNo <> s2.RepNo ;
    Is this a typo?
    Shouldn't the first "Table1 s2" be "Table1 s1"??

  3. #3
    newbieaccess203 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    21
    sorry, yes that was a typo error it is s1.
    Also is there a way to add combo box on the same form which will list this result to show for particular region ?, Here in the example I've just mention (given eg. ) of one region. But there are 25 regions. So for each region if i want to see the result. Is there a way i can list those region in combo box and select which region I want and it will show me only for those region?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    You want to apply filter criteria to a form? Review: http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    newbieaccess203 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    21
    Does anyone have answer to the original query i was looking for to display result i mention in first post ? i need to display result where records in two column have same data multiple times but different in 3rd colummn. For example from list of records I want to display result like this :

    NOTE : If you notice 2nd and 3rd column has same value in more than one rows but 5th column has different value for those duplicates

    for example: from the attach table the result should be

    MIDSOUTH 106 458296 Iron 50002239 London Repository
    MIDSOUTH 106 458296 Iron 50085661 Spain Repository

    and then there should be next button, click which will take me to next dups record so for eg. if i click next it should show me:
    MIDSOUTH 106 608013 Iron 50002239 London Repository
    MIDSOUTH 106 608013 Iron 50085661 Spain Repository

    Clicking Next should show me:

    MIDSOUTH 106 950486 Iron 50002239 London Repository
    MIDSOUTH 106 950486 Iron 50085661 Spain Repository

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Query looks good to me but really need to work with data. If you want to provide db for analysis, follow instructions at bottom of my post.

    So what is the real issue - the query works and you need to know how to display data in combobox? Sounds like a dependent (or cascading) combobox. Assuming form is bound to a master dataset of records with CityCode, combobox can have a RowSource with criteria that references the CityCode in the form's RecordSource, reference a textbox bound to CityCode:

    SELECT ... FROM queryname WHERE [CityCode]=[tbxCity];

    Then code behind the form OnCurrent event to requery the combobox when form navigates between records: Me.cbxCity.Requery

    Navigate records with the intrinsic tools or build your own buttons.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    newbieaccess203 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    21
    Again,

    If you notice I am not trying to pull the records based on condition where countrycode=citycode. I am trying to pull the records where there are multiple records with same countrycode and city code but have different Repno. See the original table. Query I build pop up text box to enter data. I just need to simply display records from this table.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Then perhaps the combobox is dependent on multiple criteria.

    If you want combobox to display limited set, that limitation must be based on some filter criteria. So how do you want to provide the filter parameters? I suggested the combobox be dependent on record of form. You could also have user input parameters into UNBOUND controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    newbieaccess203 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    21
    I am sorry but I think you are mixing two different things

    1) First Question I asked in very first post where I just need to write simple query from very simple table where few columns(countrycode and citycode) which are duplicates (more than one exactly the same) should display if another column (Repno) is different for those same records.

    2) Second Question I later ask if I can pull those records for specific region by putting combo box and select the region from that box.

    thanks

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    1. The query you posted looks good, but as stated, would need to do some testing with your data

    2. If you just want combobox to display all regions as a list to choose from and apply that choice to the dataset of step 1, review http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    newbieaccess203 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    21
    let me see if i can get you actual data and database and actual query i am trying to solve

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

Similar Threads

  1. Replies: 3
    Last Post: 06-25-2015, 12:22 PM
  2. is this possible & is this hard to do Please help
    By Debbie_P in forum Database Design
    Replies: 4
    Last Post: 02-10-2015, 08:21 AM
  3. Hard to explain how to do this?
    By flemingjo in forum Forms
    Replies: 1
    Last Post: 08-29-2014, 06:03 AM
  4. Hard Question
    By chivo123 in forum Access
    Replies: 4
    Last Post: 01-20-2012, 10:44 AM
  5. Having a hard time programmatically making reports
    By blacksaibot in forum Programming
    Replies: 6
    Last Post: 01-20-2010, 03:53 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