Results 1 to 10 of 10
  1. #1
    Tantum4 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2015
    Posts
    4

    Primary Keys for Tables & Forms

    Hi,



    I am a new to this forum so I'm not sure if this is being posted in the correct thread. So straight to my questions. I have a Database for Manifests (Cargo & Waste). For each there are two tables and two Forms with a lot of fields. For the two Forms I have concatenated the Manifest Number which identifies the records like this.. Cargo Manifest: POIN-IN-00*. And Waste Manifest: POIN-WASTE-00* (* being the auto-number). Since these are separate records (Tables) there will be a point when the Auto-number (set as Primary Key) will be the same. What I want to do is have the Primary Key compliment each other. For eg. If a new Cargo Manifest Number is POIN-IN-007 and I have to generate a new Waste Manifest I want it to be POIN-WASTE-008 continuing in this manner don't matter which manifest is used ensuring that the prefix identifies the Manifest. Can this be done in Access? If so How? Please bear in mind that this is done in a program that I use but I want to create a back-up system in the event that the program is down, which happens often as well as use the database for other manifest tracking.

    I'll be happy to share more info on my Database if necessary. Thanks for your support and ANY advice given.

    Rgds

    Tantum4
    Last edited by Tantum4; 01-29-2015 at 08:33 PM. Reason: Additional Info.

  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
    53,643
    Generating custom unique identifiers is a common topic. Here is one to review for starters https://www.accessforums.net/forms/a...ing-23329.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
    Tantum4 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2015
    Posts
    4

    Reply: Primary Keys for Tables & Forms

    Quote Originally Posted by June7 View Post
    Generating custom unique identifiers is a common topic. Here is one to review for starters https://www.accessforums.net/forms/a...ing-23329.html
    Hi,

    Don't quite understand what is being done in that link. Exactly how does it refer to what I'm trying to do? If it can be used, how can I modify the codes to reflect my issue.

    Thanks.

  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
    53,643
    It's an example of one method to generate a custom unique identifier. Cannot use autonumber fields as primary key. The code calculates a sequential identifier for each new record. This appears to be your requirement; although more complicated because you want the sequence across two tables. Very odd.
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Please describe to readers exactly what you are trying to achieve in plain English.
    How are Cargo and Waste related in business terms? As June says the request is quite strange, but we'd like to hear the rationale.

  6. #6
    Tantum4 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2015
    Posts
    4
    Ok, here goes.. Cargo Manifest is a form used to track items sent out from site via Sea. Waste Manifest is a form used to send Waste items from site via Sea. I want both to use separate tables but share progressive Manifest Number. By that I mean, as stated in above eg, when I create a Cargo and a Waste Manifest the ID Number should be one more than the other in succession. The problem is I dont want to have two manifests with the same ID Number eg. Cargo - IN -0007 and Cargo - WASTE - 0007. I hope this was explained properly.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Why do you think
    Cargo and a Waste Manifest the ID Number should be one more than the other in succession.
    will make life easier??? The numbers are just numbers?? A Cargo Manifest 23 is not the same as a Waste Manifest 23--I'm missing your point.

    It's a little like a 20 year old spectator sitting on the 20 yard line in section 20 row 20 seat 20????

    You have to look at the values in context to understand what they represent. You wouldn't confuse a 20 year old spectator with seat number 20.

    You can certainly have PurchaseOrder 20 and an Invoice number 20 and not be confused with them because they each have a 20 in their identification. Maybe I'm missing something basic???

  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
    53,643
    I understand you want one sequence for manifest. Also understand there are two types of manifest. The easiest approach would be to have one table with a field for the Type category (cargo, waste) then let autonumber assign the sequence.
    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
    Tantum4 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2015
    Posts
    4
    Thanks guys for all your advise. June7, I think I will try the approach on your last post.. I'll let you all know how it goes.

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I agree with June based on the info you have provided. However, I have a feeling you have not analyzed your processes and requirements sufficiently, yet.

    You should work through a few tutorials and get a working familiarity with database concepts and business rules.
    You may want to research -normalization, supertype/subtype and entity relationship diagramming.

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

Similar Threads

  1. primary keys in four different tables
    By greatlhanderz_15 in forum Access
    Replies: 5
    Last Post: 01-30-2013, 10:04 PM
  2. Replies: 1
    Last Post: 10-26-2012, 03:27 PM
  3. Replies: 1
    Last Post: 05-24-2012, 09:35 AM
  4. Replies: 2
    Last Post: 09-22-2010, 02:25 PM
  5. Multiple primary keys
    By elektrisk in forum Access
    Replies: 5
    Last Post: 02-11-2010, 04:39 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