Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    34

    Unanswered: Primary Key generation (Visual Basic)

    Hi,

    I have 5 tables that have Primay Key ID numbers. They are 8 char ID's but start with a 3 char prefix, e.g. VOL00001 for Volunteers table, CLT00001 for Clients table etc.

    I am having trouble retrieving the next ID in sequence when I try add a new record.

    Does anyone know of an easy way to do this?

    Regards, Rayden

  2. #2
    Join Date
    Oct 2003
    Location
    Tijeras, NM
    Posts
    12
    Call ReSync after calling Update. I think that should work.
    I love animals. They're delicious.

  3. #3
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Lightbulb is this an option

    You coud try this :

    Go to last record

    DIM X as LONG
    DIM Y AS String


    Y = mid(rs.id,1,3) 'This wil be eg "VOL" from the original VOL00001
    X = Mid(rs.id,4) 'this will give eg "00001"from the original VOL00001
    X=X+1
    format(X, "00000") 'this will prit leading zero's
    Y=Y & X


    Y will now be "VOL00002" 'This wil be your next ID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •