Results 1 to 3 of 3
  1. #1
    omegads is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    17

    Post create query to return duplicate values on different column

    Good day to all, i'm practically new and learning how to use access, what i want to do is the following, i have a table with two fields "ID" and "Username" what it basically does is record how many times the user logged in.



    ID | Username |
    -------------|-------------|
    1 | Robert |
    -------------|-------------|
    2 | Diana |
    -------------|-------------|
    3 | Robert |
    -------------|-------------|

    what i want to do is a query that returns me the records where that a particular user logged in one column

    Username | Records |
    -------------|-------------|
    Robert | 1 3 |
    -------------|-------------|
    Diana | 2 |

    i don't know if it can be done. if we need VBA to do it, no problem because i'm learning that to so i can easily understand code if we need one.

    Regards

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    It can be done in one way or another, but the question is why?
    - If your ID is an autonumber PK field it's not really supposed to be used as meaningful data.
    - putting multiple values in a field is not a grand idea either, in most cases. Only once in many years of Access have I ever encountered a situation where it was the solution.
    - with multiple values in a field comes the hassle of trying to do anything with the group or its elements
    what it basically does is record how many times the user logged in.
    Not according to what you're showing. That is ID 1 and ID 3 (basically, records 1 and 3), which is meaningless.

    Is what you show the real goal and setup or are you disguising the real situation? I ask because this happens a lot in forums.

    BTW, ID makes a poor field name as you will find out when you end up with a bunch of them.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    That requires a VBA function. Review http://allenbrowne.com/func-concat.html

    Could just sort the records by Username.
    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.

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

Similar Threads

  1. Replies: 6
    Last Post: 08-09-2018, 11:41 PM
  2. Replies: 1
    Last Post: 06-18-2014, 04:08 AM
  3. Replies: 15
    Last Post: 11-08-2012, 10:09 AM
  4. Replies: 20
    Last Post: 09-12-2012, 06:52 PM
  5. Replies: 5
    Last Post: 02-09-2011, 11:22 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