Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13

    query returning duplicates

    I have created a query from two tables. I have created a form to do multiple field search in the query but I am getting duplicates. for instance if A is mentioned just once in the table query result will show it multiple times. can anyone pzl suggest any solutions





    SQL view of the query

    SELECT DISTINCT [Logging Information].[Customer Name], [Logging Information].[Contact Date], [Logging Information].[Contact Type], [Customer Information].[Mailing Machine], [Customer Information].[Folder Inseter], [Customer Information].[Printer/Copiers], [Customer Information].Shredders, [Customer Information].[Known Software], [Logging Information].Comments
    FROM [Customer Information], [Logging Information];

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You have two tables in the query without a JOIN clause which results in a Cartesian relationship - every record of each table associates with every record of other table. Set a link in query between the key fields. Is there a customer ID in each table?
    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.

  3. #3
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    Click image for larger version. 

Name:	1.png 
Views:	23 
Size:	52.3 KB 
ID:	30418thank u but now the problem is that when I connect Table:Customer Information "ID" with the logging information "customer address" and run the query there are no results displayed.

    I am using this criteria to run the query.

    Like "*" & [Forms]![CompetitiveAssets]![Known Software] & "*"
    Attached Thumbnails Attached Thumbnails 1.png  

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Why do you duplicate the Customer Name and Address in Logging Information table? Why would you link ID with Address instead of Name? Exactly what value is saved in that Customer Name field? Is it the ID from Customer Information?

    Advise not to use spaces or punctuation/special characters (underscore is only exception) in naming convention. Better would be CustomerInformation, CustomerName, Followup_Date, Application_P, etc.
    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
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    hak.

    Step back from Access and tell us in plain English "what" you are trying to do.

    Who is the Customer? What exactly is to be logged --in simple, plain English?

    I think your table structure may be an issue, as June has noted.

  6. #6
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    Click image for larger version. 

Name:	20170923_000359.jpg 
Views:	17 
Size:	105.1 KB 
ID:	30422 i have never worked before in Access and this is the first project of the job. I have tried hard to catchup things but I am business student so there are some problems due to lack of knowledge about databases. Thank you for your help.

  7. #7
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13

    2nd post

    Click image for larger version. 

Name:	20170923_000546.jpg 
Views:	17 
Size:	116.8 KB 
ID:	30423 and this is the second page of the task that I was given

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    This is an actual job assignment or coursework?

    You didn't answer questions in post 4. Here's another - why are there CustomerName and CustomerInformation tables?
    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
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    this is an assignment that I am working as a university Intern. Its part of my program. I made two tables bcz Company A can have several different locations with different equipment and we need to identify these oppertunities at different location. I hope this answers your question

  10. #10
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    This is the link to the database in case if you want to have a close look at this ingenious work
    https://1drv.ms/u/s!Asr_jzFWEFJGaYYEPrm9iQMIU7I

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Again, advise you modify naming convention as already suggested.

    I never set lookups in tables and I never use dynamic parameterized queries. As a developer I find both of these features annoying. When I view a table I want to see the actual values in field and when I view a query I don't want to be nagged with popup inputs because a form isn't open.

    There is no need for the CustomerName field in Logging table. It can be retrieved by query linking tables.

    Use comboboxes on forms for assets. Because you are saving text description and using LIKE and wildcard in dynamic query, your comboboxes can use data saved in CustomerInformation table.

    Example RowSource for MailingMachine: SELECT DISTINCT [Mailing Machine] FROM [Customer Information] ORDER BY [Mailing Machine];

    For CompetitiveAssets and LoggingInformation, set LimitToList to Yes

    Comboboxes would also be useful on CustomerInformation form. Only instead of LimitToList set to Yes, set No so users can select from dropdown list if item already exists but still be allowed to enter new item (combobox would have to be requeried to make the new item available for selection in another record in the same edit session).

    I don't know what PotentialProducts form is about.

    Alternatively, build an Assets table and use that as source for comboboxes.
    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.

  12. #12
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    thank u so much.

  13. #13
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    so now my queries take criteria from 5 combo boxes in the forms
    Click image for larger version. 

Name:	2.png 
Views:	12 
Size:	22.1 KB 
ID:	30506
    My criteria is
    Is Null Or Like "*" & [Forms]![CompetitiveAssets]![MailingMachine] & "*"

    Click image for larger version. 

Name:	3.png 
Views:	12 
Size:	60.2 KB 
ID:	30507

    So when I run the query by selecting criteria it also shows me the empty records which I don’t want but if I remove “Null” if there is a single field empty related to the five criteria it won't show me anything at all.

    Can you plz suggest any solution for this.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Deal with the Null values by creating fields in query with expression like: Nz([Mailing Machine],"none")

    Apply the dynamic parameters to those calculated fields. You don't have to display these fields.
    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.

  15. #15
    hak is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    13
    thank you.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-17-2017, 02:14 AM
  2. Replies: 3
    Last Post: 01-18-2016, 01:55 PM
  3. help with query returning duplicates
    By BrockWade in forum Queries
    Replies: 7
    Last Post: 12-05-2013, 02:23 PM
  4. Query Returning Duplicates
    By rlsublime in forum Queries
    Replies: 14
    Last Post: 03-25-2013, 11:26 AM
  5. Querying multiple queries, returning duplicates
    By Gabriel2012 in forum Queries
    Replies: 3
    Last Post: 12-04-2012, 12:39 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