Results 1 to 4 of 4
  1. #1
    Woodster is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    2

    Cool Compare a value from one record to the previous record. No date ordering!

    I have researched solutions for this scenario but they all seem dependant on sorting the data by date.
    My situation is different.

    It may be easiest to show the data I am working with. - Table below, sorted by transaction ID

    The sequence # on the left I have just added here for reference.

    I need to flag each record as being 'Family' or Individual'.
    This is decided by whether there is just one record or more than one record for any given Family ID (e.g. 'F-TGJ7').
    i.e. Whenever more than one record has the same Family ID, then they should be flagged as 'Family', else 'Individual'.

    Sorting by date or transaction ID does not group common Family ID's, so I have to sort by Family ID
    e.g. Row 9 needs to be Family as it matches rows 5 & 6.



    Hope someone can help?

    Code:
    #	TransactionID	                        FamilyID	IndividualID	CrtDtTm
    1	TR-131613433542179357C-X2SV	F-TGJ7	I-CN9Y	2011-09-16  00:52:15Z
    2	TR-131613433542179357C-X2SV	F-TGJ7	I-L6UN	2011-09-16  00:52:15Z
    3	TR-131613445998279400C-X2SV	F-TGJ7	I-CN9Y	2011-09-16  00:54:20Z
    4	TR-131613445998279400C-X2SV	F-TGJ7	I-L6UN	2011-09-16  00:54:20Z
    5	TR-131613491817979503C-HCHB	F-ZXO7	I-G6B0	2011-09-16  01:01:58Z
    6	TR-131613504264679528C-HCHB	F-ZXO7	I-G6B0	2011-09-16  01:04:02Z
    7	TR-131613606671179827C-X2SV	F-TGJ7	I-CN9Y	2011-09-16  01:21:06Z
    8	TR-131613606671179827C-X2SV	F-TGJ7	I-L6UN	2011-09-16  01:21:06Z
    9	TR-131613609068079825C-HCHB	F-ZXO7	I-G6B0	2011-09-16  01:21:30Z
    10	TR-131613743160080211C-XK0I	F-A2V1	I-0UTG	2011-09-16  01:43:51Z
    11	TR-131613743160080211C-XK0I	F-A2V1	I-E719	2011-09-16  01:43:52Z
    12	TR-131613743160080211C-XK0I	F-A2V1	I-LMQZ	2011-09-16  01:43:51Z
    13	TR-131613743160080211C-XK0I	F-A2V1	I-TB0W	2011-09-16  01:43:51Z
    14	TR-131614036182881113C-ZI19	F-T89T	I-ZH9P	2011-09-16  02:32:41Z
    15	TR-131614558696482407C-RR02	F-HO6A	I-A86N	2011-09-16  03:59:47Z
    16	TR-131648472222518046C-38HE	F-1QRO	I-6GVD	2011-09-20  02:12:02Z
    17	TR-131648472222518046C-38HE	F-1QRO	I-TCQF	2011-09-20  02:12:02Z
    (and BTW I realise some Individuals have multiple records. These will be sorted out later.)

    Thanks,

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You need to do a Totals query that will count the occurrance of each FamilyID (SELECT FamilyID, Count(FamilyID) As CountOfID FROM tablename GROUP BY FamilyID). Then can join this query to the table on the FamilyID. This will give you the 'flag'. Any records showing count greater than 1 are 'family'.
    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
    Woodster is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    2
    I see where you're going thanks and I tried the query ...

    But unfortunately what I get is a count of transactions (1 transaction = 1 record)
    per Family ID.

    No family ID has only 1 record.

    In fact even a case where there is only one person for a Family ID can still have unlimited transactions/records.

    So what I need is a count of Individual ID's per Family ID, right?

    But how do I do that?

    Thanks.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Shouldn't matter which field is in the Count. (I tested.) The count is of records. But go ahead and try the change.

    You used the query I suggested? Show your exact SQL statement.
    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: 8
    Last Post: 07-06-2013, 05:13 PM
  2. Replies: 1
    Last Post: 07-25-2011, 09:41 AM
  3. Replies: 1
    Last Post: 04-21-2011, 11:27 AM
  4. Subtract From Previous Record Using a Date
    By txrules in forum Queries
    Replies: 1
    Last Post: 12-30-2010, 02:10 AM
  5. Populate date from previous record
    By Lianes in forum Access
    Replies: 3
    Last Post: 09-19-2009, 03:42 PM

Tags for this Thread

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