Results 1 to 9 of 9
  1. #1
    soul786 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Nov 2015
    Posts
    10

    multiple branch primary key conflict

    I made basic invoice app. As long as i used it for 1 store it worked fine. It is ladies garment store. Problem started with 2nd branch. I want to see data of both branches in 1 main computer. I tried export import through email and not persistent online connection. The problem is that sales id, invoice id etc primary keys r autonumbers so have same values per branch. If i try to import i cant because pk values r same.


    if somehow i can add branch code in all those ids i hope the problem will solve. Because that will make it unique even between branches. I dont know how. Please advice a no coding solution. I dont know programming.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Before you do anything, make copies of your databases.

    Rather than using AutoNumber with Long Integer field size, you might get what you want using Autonumber with Replication ID field size. You can make the adjustment in design view of your tables. However, you will need to do some importing of data. Depending on how your DB is set up, you might be able to use Relationships and Referential integrity rules to assist the process.

  3. #3
    soul786 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Nov 2015
    Posts
    10
    Quote Originally Posted by ItsMe View Post
    Before you do anything, make copies of your databases.

    Rather than using AutoNumber with Long Integer field size, you might get what you want using Autonumber with Replication ID field size. You can make the adjustment in design view of your tables. However, you will need to do some importing of data. Depending on how your DB is set up, you might be able to use Relationships and Referential integrity rules to assist the process.
    hi, thanks
    replication id may do the job, but it is not good choice, first it consumes lots of memory, 2nd it is not meaningful for humans etc.
    what i want is like i have branches RB and KB
    sales, invoice IDs etc. of say KB is
    KB-1, KB-2 and so on, it is meaningful and consumes less resources
    this is not possible with autonumber,
    i tried format option, but it just shows prefix KB along with autonumber but not actually saves it

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You lost me after, "first it consumes lots of memory...". Perhaps your best bet is to hire a consultant. I say this because you mentioned that you do not understand programming.

  5. #5
    thuzkee02 is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Location
    Dubai, United Arab Emirates
    Posts
    6
    I encountered the same problem on my project. I think the problem there is that when you call 2 or more primary keys from different Tables and use it on your query, it automatically adopts the properties of the fields themselves.

    What I did was declare the property of the field on the query itself: SELECT tableA.ID, CLNG(TableB.ID) AS ID_b or something to this effect. It worked for me.

    Hope it works for you!

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    sounds like you are trying to use the autonumber as a meaningful value (an invoice number) - which is a big no no. All an autonumber does is identify a record, no more, no less and should not be used for anything meaningful - which is why the replicationID is an acceptable alternative for your situation

  7. #7
    soul786 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Nov 2015
    Posts
    10
    thanks all
    i found a solution
    i used composite primary key, also i can use
    sequential numbering with prefixes so i get auto generated numbers as a1,a2,a3 where prefix is a

    see my solution for forms
    1.
    me.control (for respective field name) = nz(DMax("field name", "table name"), starting value) + 1
    put this code in form's design view, in form's event property before insert
    this works even if the field is text field
    2.
    me.control (for respective field name) = "string" & nz(mid(DMax("field name", "table name"),starting place), starting value) + 1
    string = anything text
    for mid function example, if field = a9, starting place = 2, answer is 9

  8. #8
    soul786 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Nov 2015
    Posts
    10
    friends
    pls advice whether to use composite key method or sequential numbering method
    composite key method consumes much more memory as more columns r required, but is easier
    sequential numbering needs coding for every front end and again if say business expands in different states then along with branch code, there must be state code
    for many tables like sales, sales returns, purchase, purchase returns, expenses, employees etc all must contain prefix as per different branches.
    front end for every branch must be edited with different prefix
    please advice any other method or suggestion or help me choose between these 2
    and now i dont mind writing or using vba

  9. #9
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    personally I would go for two/three separate columns - one to identify the branch, one to determine an incremental number and a third to determine document type

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

Similar Threads

  1. Single Primary Key for Multiple Tables?
    By lwflip in forum Database Design
    Replies: 2
    Last Post: 07-14-2015, 07:59 AM
  2. Replies: 6
    Last Post: 04-28-2014, 12:41 PM
  3. Replies: 3
    Last Post: 05-22-2013, 01:56 PM
  4. Multiple Primary Keys
    By JonathanOz in forum Access
    Replies: 2
    Last Post: 03-22-2013, 08:32 AM
  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