Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    rustynails is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    25

    Quote Originally Posted by ssanfu View Post
    Must be A2002/2003 format. I can't open it in A2000 . I'll try and look at it tonight.
    I've attached Access 2000 mdb for you
    Attached Files Attached Files

  2. #17
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I've been trying to come up with "The Rules"

    This is what I have so far: (in general)
    1) If there is a record in schedule and a record in actual, then add it to the NewTable
    2) If there is a record in schedule but not a record in Actual, then add it to the NewTable
    3) If there is not a record in schedule but there is a record in Actual and tbnum is consecutive (1, 2, 3, ....), then add it to the NewTable
    4) If there is not a record in schedule but there is a record in Actual, then ignore it


    Sch
    Sch
    Actual
    Actual
    Result
    row# odpair
    tbnum
    variation
    tbnum
    newtable
    1 JFKATL 1 JFKATL 1 Add
    2 JFKATL 2 JFKATL 2 Add
    3 JFKATL 3 Add
    4 PHXLAS 5 Add
    5 MSPSEA 4 Add
    6 PHXORD 4 ignore
    7
    ORDSLC
    4



    Add
    8


    ORDSLC 5
    Add, but change tbnum from 5 to 400

    Can you write down more rules?

    I am still unclear about row 7 & 8 - how do you decide when to change the tbnum?
    Last edited by June7; 07-27-2013 at 01:56 PM. Reason: fix typo on rule numbering

  3. #18
    rustynails is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    25
    Quote Originally Posted by ssanfu View Post
    I've been trying to come up with "The Rules"

    This is what I have so far: (in general)
    1) If there is a record in schedule and a record in actual, then add it to the NewTable
    2) If there is a record in schedule but not a record in Actual, then add it to the NewTable
    3) If there is not a record in schedule but there is a record in Actual and tbnum is consecutive (1, 2, 3, ....), then add it to the NewTable
    4) If there is not a record in schedule but there is a record in Actual, then ignore it


    Sch
    Sch
    Actual
    Actual
    Result
    row# odpair
    tbnum
    variation
    tbnum
    newtable
    1 JFKATL 1 JFKATL 1 Add
    2 JFKATL 2 JFKATL 2 Add
    3 JFKATL 3 Add
    4 PHXLAS 5 Add
    5 MSPSEA 4 Add
    6 PHXORD 4 ignore
    7
    ORDSLC
    4



    Add
    8


    ORDSLC 5
    Add, but change tbnum from 5 to 400

    Can you write down more rules?

    I am still unclear about row 7 & 8 - how do you decide when to change the tbnum?
    Whee, you got it ssanfu

    For row 7 and 8 here's the deal. You change tbnum when you encounter scenario 2 and create a new timeband. You change it because tbnum gives you a specific timeband, but in scenario 2, you create a new timeband (800-945), so for that reason you assign it a new tbnum. I just multiply it by 100, so the new timeband will be 500 in our case. dont worry about writing a query to change the timeband itself...just multiply it's associated tbnum by 100 and I'll take care of the rest.

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I have this much so far.

    SELECT odpair, tbnum, segment, flight_type, service, timeband, "S" AS Source FROM Schedule
    UNION SELECT variation, tbnum, segment, flight_type, service, timeband, "A" FROM (SELECT Actual.segment, Actual.flight_type, Actual.service, Actual.timeband, Actual.tbnum, Actual.variation
    FROM Actual LEFT JOIN Schedule ON (Actual.variation = Schedule.odpair) AND (Actual.tbnum = Schedule.tbnum)
    WHERE (((Schedule.odpair) Is Null) AND (Not (DLookUp("odpair","Schedule","odpair='" & [variation] & "'")) Is Null))) AS Q;

    Sub Reconciliation()
    '1) If there is a record in schedule and a record in actual, then add it to the NewTable
    '2) If there is a record in schedule but not a record in Actual, then add it to the NewTable
    '3) If there is not a record in schedule but there is a record in Actual and tbnum is consecutive (1, 2, 3, ....), then add it to the NewTable
    '4) If there is not a record in schedule but there is a record in Actual, then ignore it
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("ScheduleActualUNION")
    Debug.Print rs.RecordCount
    'Here it gets really tricky. Need code to loop through recordset and adjust tbnum (and timeband if you want) if needed and write record to NewTable.
    End Sub
    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. #20
    rustynails is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    25
    Quote Originally Posted by June7 View Post
    I have this much so far.

    SELECT odpair, tbnum, segment, flight_type, service, timeband, "S" AS Source FROM Schedule
    UNION SELECT variation, tbnum, segment, flight_type, service, timeband, "A" FROM (SELECT Actual.segment, Actual.flight_type, Actual.service, Actual.timeband, Actual.tbnum, Actual.variation
    FROM Actual LEFT JOIN Schedule ON (Actual.variation = Schedule.odpair) AND (Actual.tbnum = Schedule.tbnum)
    WHERE (((Schedule.odpair) Is Null) AND (Not (DLookUp("odpair","Schedule","odpair='" & [variation] & "'")) Is Null))) AS Q;

    Sub Reconciliation()
    '1) If there is a record in schedule and a record in actual, then add it to the NewTable
    '2) If there is a record in schedule but not a record in Actual, then add it to the NewTable
    '3) If there is not a record in schedule but there is a record in Actual and tbnum is consecutive (1, 2, 3, ....), then add it to the NewTable
    '4) If there is not a record in schedule but there is a record in Actual, then ignore it
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("ScheduleActualUNION")
    Debug.Print rs.RecordCount
    'Here it gets really tricky. Need code to loop through recordset and adjust tbnum (and timeband if you want) if needed and write record to NewTable.
    End Sub
    Awesome. Thank you. I should be able to work out the rest. Thx

  6. #21
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I was using a more VBA approach, but June's method is better.

    Good luck with your project.....

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I went in numerous circles trying a strictly VBA approach opening and looping recordsets to try and produce the dataset I eventually configured with the nested query object. At that point, I found the remaining 'rules' too fuzzy for me to continue.
    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
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @June
    I opened a union query to get the distinct odpair/variations. (There would be one record for JFKATL)
    Then I opened a record set on Schedule, filtered on odpair. Same with Actual.

    Then tried to create the logic. Since I didn't understand the rules enough, I went into an endless loop.....


    I need a lot more experience/knowledge on making queries like the one you created... <sigh> (One query to do what I tried to do with 3..)

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I use the query builder to help construct queries then copy/paste SQL into other SQL to get the nested 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.

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

Similar Threads

  1. Replies: 12
    Last Post: 04-25-2013, 01:32 PM
  2. Replies: 4
    Last Post: 11-21-2012, 03:17 PM
  3. Replies: 1
    Last Post: 12-01-2010, 11:01 AM
  4. Compare tables and tell me differences
    By cowboy in forum Programming
    Replies: 2
    Last Post: 08-11-2010, 08:32 AM
  5. Compare two tables
    By Igli in forum Access
    Replies: 2
    Last Post: 07-05-2010, 10:30 AM

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