Results 1 to 3 of 3
  1. #1
    broecher is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Sep 2010
    Posts
    38

    use data from record 2 in record 1

    I have a database with location data that looks like this:

    Lat, Long, Fix#
    A, B, 1
    C, D, 2
    E, F, 5
    G, H, 7

    I want to export a file that will be in the correct format for me to generate lines in another app. So I want to make it look like this:

    OriginLat, OriginLong, DestLat, DestLong
    A, B, C, D
    C, D, E, F
    E, F, G, H
    G, H,,,

    Fix# is in the correct chronological order, but since fixes are missing in the record, fix# is not consecutive. I also have fields for the time but I ommited them in the example.

    One option i have been trying is to find a way to number them consecutivley, then I could make a second field that is [first]+1 and then make a relationship between them.

    Query1
    Lat, Long, Fix#, counter
    A, B, 1, 1
    C, D, 2, 2
    E, F, 5, 3
    G, H, 7, 4



    Query2
    Lat, Long, Fix#, expr: [counter]+1
    A, B, 1, 2
    C, D, 2, 3
    E, F, 5, 4
    G, H, 7, 5

    I used this code to number them: http://www.trevor.easynet.co.uk/AccF...es.htm#counter But the problem is that they are not numbered in the right order. It almost looks random in fact.

    If anyone has an idea of how to make the counter number them in order, or how to do this whole thing some other way let me know.

    Thanks!

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    Once you do have the consecutive numbering i.e.
    Query1
    Lat, Long, Fix#, counter
    A, B, 1, 1
    C, D, 2, 2
    E, F, 5, 3
    G, H, 7, 4

    then you want to make a new query using this record set (i.e. Query1) - in design grid put the same record set up twice and put the join between them on the 'counter' field - and add all the appropriate fields so that this query runs...but in this step 1 will be joined to 1, 2 to 2 etc.... once that works, then switch to sqlview and modify the join language to include a +1 ....so now 1 will join to 2 (rather than 1)...

    hope this helps.

  3. #3
    broecher is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Sep 2010
    Posts
    38
    Thanks, Changing the SQL to say -1 sounds a lot easier. Found an easier way to add the counter here:

    http://www.vb123.com/toolshed/07_acc...ntercolumn.htm

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

Similar Threads

  1. include zero data where no record
    By Sandy Gomez in forum Access
    Replies: 4
    Last Post: 09-15-2010, 06:23 AM
  2. Replies: 5
    Last Post: 06-29-2010, 01:24 PM
  3. Replies: 3
    Last Post: 06-27-2009, 03:53 PM
  4. Find data, load data, and save as a new record
    By hawzmolly in forum Access
    Replies: 0
    Last Post: 10-05-2008, 03:18 PM
  5. Deleting Record Contents, not complete record...
    By Charles Waters in forum Access
    Replies: 2
    Last Post: 06-24-2008, 12:00 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