Results 1 to 7 of 7
  1. #1
    Antonio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    37

    Selecting records with missing dates where multiple records exist

    Hi there,




    One more problem I need a solution to:

    I have uploaded another sample of data, and from this dataset, I need to select records where the 'Constituent ID' field is NOT unique (i.e. where there are 2 or more 'Constituent ID's) AND where at least one record has an empty date in the 'Constituent Specific Attributes Contact Preferences Date' field.

    Also, for every 'Constituent ID' that meets this criteria, I want to output ALL the records with that 'Constituent ID' (e.g. if the dataset contains a Constituent ID that is duplicated 5 times, and 1 of the records has a missing date, this record would be selected, and all 5 records would be outputted).

    A few examples of returned records from the uploaded dataset would be:

    Constituent ID
    Constituent Specific Attributes Contact Preferences Import ID
    Constituent Specific Attributes Contact Preferences Description
    Constituent Specific Attributes Contact Preferences Date
    2259 00001-528-0000449513 Email opt out 02/11/2016
    2259 00001-528-0000046474 Email opt in
    2637 00001-528-0000129918 Email opt in 05/04/2016
    2637 00001-528-0000273247 Postal opt out
    2637 00001-528-0000273248 Telephone opt out

    Again, as I like to work in SQL, if anyone has any ideas, could you type the SQL statement in your solution?

    Any help, as always, much appreciated.


    Thanks,

    Antonio
    Attached Files Attached Files

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Hi Antonio,
    Have a look at the attached file (sorry I just saw you uploaded yours), look at the qryConstituentsWithMissingDate_AND_MultipleRecords query.
    Cheers,
    Vlad
    Attached Files Attached Files

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    So Antonio, have you had time to look at my sample?

    Vlad

  4. #4
    Antonio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    37
    Hi Vlad,


    Apologies for the late reply, as I explained in an earlier post, because I am doing work on behalf of a client and have deadlines to meet and expectations to manage, I need to sometimes 'prematurely' ask questions so that I can be ready when I actually need them!

    But yesterday I implemented your solution and it works perfectly. I also understand why you split the queries into out, because in order to display all the fields from Constituent, you had to join this to your aggregate queries (because I get th e impression that its not easy (maybe impossible) to output the full data from an aggregate query).

    It was very helpful, thanks very much, much appreciated.



    Antonio

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You're welcome, glad you got it working!

    Vlad

  6. #6
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by Antonio View Post
    I also understand why you split the queries into out, because in order to display all the fields from Constituent, you had to join this to your aggregate queries (because I get th e impression that its not easy (maybe impossible) to output the full data from an aggregate query).
    You often have to aggregate just the data you need , then rejoin to your Original data as otherwise the aggregate fails because of the additional data in the record.

    This is particularly true if counting occurrences with datetime fields. Anything with a time element is likely to be a unique record, so if you include it in your grouping, you end up with many "Distinct" records.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    Antonio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    37
    Yes you have confirmed my thinking, and more! I will bear that in mind, especially when handling datetime fields.

    Thanks Minty.

    Antonio

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

Similar Threads

  1. Replies: 6
    Last Post: 03-17-2017, 10:28 PM
  2. Replies: 4
    Last Post: 07-10-2015, 07:51 AM
  3. Replies: 4
    Last Post: 03-03-2015, 01:36 PM
  4. Update dates for multiple (not all) records
    By thekruser in forum Access
    Replies: 2
    Last Post: 08-30-2010, 05:27 PM
  5. Selecting multiple records in drop down
    By rscott7706 in forum Access
    Replies: 1
    Last Post: 08-26-2009, 03:00 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