Results 1 to 11 of 11
  1. #1
    july1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Posts
    5

    Unhappy Duplicates in Query but not Table

    Hi friends,

    I was doing an Access project and when I did a query for the Table "Customers" with primary key set to ID, there are duplicate values for my query.
    However, there are no duplicate values for my "Customers" table. Tried using Query to find duplicates but to no avail.

    How can I delete the duplicate values under queries / tables (where can I even find the duplicates?)?

    Besides, sometimes when I add in a record under Table "Customers", the entry will be deleted after I press enter / go to the next entry.
    Thus, I reentered the entry but on a different ID number (since it runs on auto number).

    Is this a common problem of access?

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Post your SQL statement and what you are attempting to achieve.

  3. #3
    july1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Posts
    5
    Hi alansidman,

    I want to filter customers with transaction dates before 2001.
    But I have duplicate values of ID.
    When searched the Table, there are no duplicates. Thus I am confused.

    SQL:

    SELECT [Customer Details].ID, [Car Details].[Registration Date], [Customer Details].[Vehicle Number], [Car Details].[Car Make], [Car Details].[Car Model], [Car Details].[New/Used], [Customer Details].[First Name], [Customer Details].[Last Name], [Customer Details].Gender, [Customer Details].Address, [Customer Details].[Postal Code], [Customer Details].[Mobile Number], [Customer Details].[Alternate Number], [Customer Details].[NRIC/FIN], [Customer Details].DOB, [Customer Details].[Email Address], [Customer Details].Remarks
    FROM [Car Details] INNER JOIN [Customer Details] ON [Car Details].[Vehicle Number] = [Customer Details].[Vehicle Number]
    WHERE ((([Car Details].[Registration Date])<#1/1/2003#));

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Can customer have multiple cars?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    In addition to June's question, can a car have more than one owner listed in the customer file. Spouses both listed as separate records? Father/Son? etc.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    How about telling us about the business related to this database and query?
    Using simple English, clearly give us an overview of a day at the office in terms of Cars and Customers.

    Here is sql for the query --formatted by PoorSQL
    Code:
    SELECT [Customer Details].ID
    	,[Car Details].[Registration Date]
    	,[Customer Details].[Vehicle Number]
    	,[Car Details].[Car Make]
    	,[Car Details].[Car Model]
    	,[Car Details].[New/Used]
    	,[Customer Details].[First Name]
    	,[Customer Details].[Last Name]
    	,[Customer Details].Gender
    	,[Customer Details].Address
    	,[Customer Details].[Postal Code]
    	,[Customer Details].[Mobile Number]
    	,[Customer Details].[Alternate Number]
    	,[Customer Details].[NRIC/FIN]
    	,[Customer Details].DOB
    	,[Customer Details].[Email Address]
    	,[Customer Details].Remarks
    FROM [Car Details]
    INNER JOIN [Customer Details] ON [Car Details].[Vehicle Number] = [Customer Details].[Vehicle Number]
    WHERE ((([Car Details].[Registration Date]) < #1 / 1 / 2003 #));
    Many recommend that you do not use names with embedded spaces or special characters ('/'). Using such will cause you syntax errors --sooner or later.

  7. #7
    july1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Posts
    5
    Yes, a car can have multiple owners - changed hands
    No, spouses will not be listed. only the registered car owner.

  8. #8
    july1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Posts
    5
    yes, customer can have multiple cars.
    is that for both excel and access?

  9. #9
    july1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Posts
    5
    we are in a car dealer business. we buy in new and used cars and of course, sell to other people. i will want to include all the information related to the car and customer.
    initially i created 2 tables - car and customers - and linked it up via the vehicle plate.
    but as i was keying in the data, and pressed 'delete' by accident or sometimes simply a 'space', the whole row of data will disappear. as such, i will have to reenter the data but my auto number function will continue running (instead of 100, it is now 101). this is my main concern.

    i believe that this is related to the problem of data duplication that appeared under queries and not the table. i have solved this by exporting out to excel and importing it back to access but not the former.

    'Many recommend that you do not use names with embedded spaces or special characters ('/'). Using such will cause you syntax errors --sooner or later.'

    i should just use 'CustomerDetails' instead of 'Customer Details'?
    what difference does it make?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Names with spaces and/or punctuation/special characters will always require to be enclosed in [ ] when referenced. Believe me, someday you will forget and suffer the consequences.

    Access will often try to supply the [ ] (in queries mostly) if you don't but can't distinguish name if it has spaces etc. VBA will not try to supply missing [ ].

    I have encountered situation where the [ ] was required regardless and had to be deliberately typed but I can't remember exact circumstances.

    Vehicles can have more than one owner named on title.

    Do you care about history of car ownership or just the current owner?

    An autonumber type field primary key is not supposed to have meaning to users and therefore gaps in sequence should be disregarded. Not really understanding how this would contribute to duplicate ID in query.
    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
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I'm not sure what your tables and relationships are, but you appear to have a M:N relationship. Also called many to many.
    That is,
    a Car may have 1 or Many Owners, and
    an Owner may own 1 or Many Cars


    the Many here means at the same time. This 2016 Chev is owned by John Doe and Patty O'Khair.

    In relational database, this is resolved using a junction table, also called linking table or mapping table or associative entity.

    Here's a related article and another.

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

Similar Threads

  1. Append Query to a table (Without Duplicates)
    By cmorten in forum Queries
    Replies: 12
    Last Post: 11-28-2016, 02:44 PM
  2. Replies: 3
    Last Post: 09-11-2015, 03:22 PM
  3. Query outputs duplicates from 1 table
    By Govman in forum Queries
    Replies: 1
    Last Post: 02-16-2015, 06:01 PM
  4. Replies: 4
    Last Post: 09-23-2011, 11:56 AM
  5. Replies: 7
    Last Post: 04-15-2011, 08:46 AM

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