Results 1 to 11 of 11
  1. #1
    contfe is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    6

    Help I need to create a field that auto counts up based on another field's data....

    Hello,

    So I need to make a .csv file with order tracking information. I get the database already from a .csv but I'm using access to store it an manipulate it (too much information for excel). These are the fields I get:

    Tracking #
    Order ID
    Date


    Carrier

    But I need to make this into:

    Order ID
    LineNumber
    Carrier
    Tracking Number

    So I need assistance with the LineNumber field. This field is has to be auto-number based on the Order ID, IE: If an order has multiple packages and they were sent on different trucks or carriers, I would have multiple tracking#s for a single Order ID, the LineNumber has to organize them by means of an counter that counts each new tracking number from 0 up, like:

    Order ID LineNumber Tracking#
    10001 0 abc
    10002 0 abc
    10002 1 abd
    10003 0 abd
    10002 2 abe
    10003 1 abe

    ....Help!

    this is what I've done so far:
    1. I created a table with all the fields I receive.
    2. I created a query that appends into a table all my OrderIDs without repetition
      1. this table only has one field, an FK, and has a one-to-many relationship to my master table OrderID.

    3. I created a second query that appends all the fields plus it creates a unique value by conniving the OrderID with the Date and the Tracking#
      1. this is my FK to avoid adding a record twice since the original .csv laps with the previews one I get.

    4. I made a query from which I intend to export the .csv I need to submit.


    Thank You!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You need this LineNumber for the export to CSV?

    Can run another UPDATE action that will populate the LineNumber field. Review https://www.accessforums.net/access/...eld-34175.html
    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
    contfe is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    6
    I'm still lost,

    Following the threads there was a suggestion of using DCount, but I had discount this since I'm uploading the records all at once with a .csv file upload...

    Maybe I missed something, plz help!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can't create the value during import if you are using the import wizard. Run the UPDATE to populate that field after completing the import.

    If you are not using the import wizard, how are you importing the csv data?
    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. #5
    contfe is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    6
    Yes to Wizard, I figured that i would have to add this value to the database once is added to the master or when I use the query to append the new items to the master.

    My question is how?

    Is there an equation that I can use that would add these value as I append the information to the master? (keeping in mind that I got to use the records already in the master to come up with the next value on several of these records)

    or is there a way to use vba to add these value? (I'm extremely new at VBA which is probably why I'm so lost...)

    Thank you for your help, I'll look forward to your suggestions.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You are not importing directly to 'master'?

    No, the counter field cannot be populated using Access INSERT query object.

    Once records have been imported (appended) to table, run an SQL action to UPDATE the counter field. The method using DCount() as shown in referenced link is the only way I know a query can do that.

    Yes, VBA could accomplish but that may be more complicated than the UPDATE sql, especially if you are not experienced programmer.
    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.

  7. #7
    contfe is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    6
    can you walk me down the process or link me to a board on the subject?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The referenced link is the best 'walk through' I can offer for query method. I have no idea what you mean by 'board' - another forum?
    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.

  9. #9
    contfe is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    6
    Yes Forum, Which should I look for?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't know any other specific forum for this issue.

    If the given reference does not help (what do you not understand?), you can Google to try and find more.
    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.

  11. #11
    contfe is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2013
    Posts
    6
    Thank you!

    ...I'm still lost but you help give me some direction

    Thank you!

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

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2013, 04:50 PM
  2. Replies: 7
    Last Post: 08-16-2012, 02:16 PM
  3. Replies: 10
    Last Post: 11-21-2011, 02:56 AM
  4. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  5. Replies: 5
    Last Post: 01-20-2011, 11:36 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