Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153

    Here is the data base. My tables are all "linked" tables so I don't think you will be able to pull any data from them. Let me know if I need to do anything else.AltBallotFormatTrackingAPP_Reporting - Copy.zip

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    I can't test query without data. You would have to import to Access 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.

  3. #18
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    OK I have finally got a table that has data in it. Although some other tables are linked, the major table is the one I am trying to use for this particular query. Again thank you so much for your patience and assistance.

    AltBallotFormatTrackingAPP_Reporting - Copy.zip

  4. #19
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    Bump - Haven't heard anything back from you. Everything ok?

  5. #20
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    Lost track of this.

    I was trying to avoid domain aggregate but tried it to compare:

    SELECT dbo_kc_alt_tracking.voter_id, dbo_kc_alt_tracking.election_id, dbo_kc_alt_tracking.TransmissionType, dbo_kc_alt_tracking.TrackingNumber, DCount("[election_id]","[dbo_kc_alt_tracking]"," [TransmissionType]='" & [TransmissionType] & "' AND [TrackingNumber]=" & [TrackingNumber]) AS MatchCount
    FROM dbo_kc_alt_tracking
    WHERE (((DCount("[election_id]","[dbo_kc_alt_tracking]"," [TransmissionType]='" & [TransmissionType] & "' AND [TrackingNumber]=" & [TrackingNumber]))>0))
    ORDER BY dbo_kc_alt_tracking.TransmissionType, dbo_kc_alt_tracking.TrackingNumber;

    The data in db does not reconcile with the example in post 3.
    voter_id election_id TransmissionType TrackingNumber MatchCount
    40196366 1259 Email 101 2
    991065134 1261 Email 101 2


    There are MANY records that meet the criteria you defined. A partial list:
    voter_id election_id TransmissionType TrackingNumber MatchCount
    40196366 1259 Email 101 2
    991065134 1261 Email 101 2
    760620971 1261 Email 102 2
    40196854 1259 Email 102 2
    980489213 1261 Email 103 2
    940519152 1259 Email 103 2
    970463275 1259 Email 104 2
    991359666 1261 Email 104 2
    970463267 1259 Email 105 2
    910298968 1261 Email 105 2
    20366117 1261 Email 106 2
    274496 1259 Email 106 2
    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.

  6. #21
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    I apologize for not being clear. When I look thru the records. I have a code that I use that pulls the most recent "Election ID" so in this case the most current "Election id" is going to be 1261. The code I use in all my queries is (select election_id from dbo_election where default_election ="y") This code just pulls the election that I work in.

    Does that makes sense? So for the above examples, Right now the current election is the "election id" with a value of 1261 (it goes up 1 for every election that we have).

  7. #22
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    That field not in the db posted. Without the field, more complicated because need to get the Max election_id with another subquery or DMax().

    Try adding it as criteria in the suggested queries. It would have to be included in the DCount() expression.
    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.

  8. #23
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    I dont get that. Because if you just put in the code that i put above in the query (this code would go in the criteria box under "election_id" then it would automatically just pull the most current records using only 1 election id. Are you able to do that?

  9. #24
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    SELECT dbo_kc_alt_tracking.voter_id, dbo_kc_alt_tracking.election_id, dbo_kc_alt_tracking.TransmissionType, dbo_kc_alt_tracking.TrackingNumber, DCount("*","[dbo_kc_alt_tracking]","election_id=" & [election_id] & " AND [TransmissionType]='" & [TransmissionType] & "' AND [TrackingNumber]=" & [TrackingNumber]) AS MatchCount
    FROM dbo_kc_alt_tracking
    WHERE (((dbo_kc_alt_tracking.election_id)=1261) AND ((DCount("*","[dbo_kc_alt_tracking]","election_id=" & [election_id] & " AND [TransmissionType]='" & [TransmissionType] & "' AND [TrackingNumber]=" & [TrackingNumber]))>1))
    ORDER BY dbo_kc_alt_tracking.TransmissionType, dbo_kc_alt_tracking.TrackingNumber;


    voter_id election_id TransmissionType TrackingNumber MatchCount
    970303332 1261 NS Mail 10 2
    840471659 1261 NS Mail 10 2
    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.

  10. #25
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    Wow!!

    I would have never gotten that without your help! That is great!! Thank you so much for your patience and all your help with this code!

  11. #26
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    Be aware domain aggregate can be very slow. Here is the other approach, corrected for the election_id. I should have seen this before, did cross my mind the election_id could be important but didn't follow through.

    SELECT dbo_kc_alt_tracking.voter_id, dbo_kc_alt_tracking.election_id, dbo_kc_alt_tracking.TransmissionType, dbo_kc_alt_tracking.TrackingNumber
    FROM dbo_kc_alt_tracking AS dbo_kc_alt_tracking_1 INNER JOIN dbo_kc_alt_tracking ON (dbo_kc_alt_tracking.election_id = dbo_kc_alt_tracking_1.election_id) AND (dbo_kc_alt_tracking_1.TransmissionType = dbo_kc_alt_tracking.TransmissionType) AND (dbo_kc_alt_tracking_1.TrackingNumber = dbo_kc_alt_tracking.TrackingNumber)
    WHERE (((dbo_kc_alt_tracking.voter_id)<>[dbo_kc_alt_tracking_1].[voter_id]) AND ((dbo_kc_alt_tracking.election_id)<>[dbo_kc_alt_tracking_1].[av_election_id]));

    voter_id election_id TransmissionType TrackingNumber
    840471659 1261 NS Mail 10
    970303332 1261 NS Mail 10
    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.

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

Similar Threads

  1. Query fails to find matching records
    By cowman in forum Queries
    Replies: 5
    Last Post: 03-30-2013, 04:14 PM
  2. Replies: 8
    Last Post: 05-05-2012, 02:01 PM
  3. Replies: 1
    Last Post: 10-24-2011, 08:01 AM
  4. Replies: 1
    Last Post: 08-11-2011, 11:33 AM
  5. Replies: 6
    Last Post: 02-10-2011, 07:09 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