Results 1 to 4 of 4
  1. #1
    rob4465 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    4

    Loop through Records and Make ID

    Hi there - I'm doing a database that will need to link with a Paradox database. To accomplish this I need to make a certain field in Access.



    I basically have a table that contains a persons first name and surname.

    I need to create another field called ID Make that takes the first six characters of the first name, adds in a hyphen and then adds in the first character of the surname.

    I can do this easily with a query like:
    Left([First Name],6) & "-" & Left([Surname],1)

    For example the name William Gates would be turned into:

    Willia-G

    Now here comes the tricky bit, if there is another William Gates I would get another Willia-G reference but at this point I need it to add a '1' at the end so I would get:

    Willia-G1

    If there was a third I would need Willia-G2.... and so on.

    What I could do with is some kind of script that looks at each record in the table and then makes the appropriate ID.

    I'd appreciate very much any help anyone can give me.

    At the moment I just have a test table called tbl_test

    Field: First Name
    Field: Surname
    Field: ID Make

    Thanks very much -

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Now you know why it is not recommended that a name be used as an ID number. Do you need this ID Make value to access the records in the table?

  3. #3
    rob4465 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    4
    Thanks RuralGuy - yes, I'm aware of this - the field I'm trying to make will not be used as an ID field but as a way to link to a paradox db.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Your loop will need either a FindFirst on the RecordSetClone or a DLookup() on the current Make ID you are creating to check for duplicates. There may be other ways as well.

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

Similar Threads

  1. Issue with while loop and Access 2007 datasheet
    By jermaine123 in forum Programming
    Replies: 2
    Last Post: 01-17-2010, 10:09 AM
  2. For Each LOOP statement
    By zambam737 in forum Programming
    Replies: 3
    Last Post: 10-26-2009, 09:59 PM
  3. update table in loop based on IF statement
    By LALouw in forum Access
    Replies: 0
    Last Post: 07-26-2009, 08:46 PM
  4. concatenate string using loop
    By nengster in forum Programming
    Replies: 0
    Last Post: 02-23-2009, 08:05 PM
  5. Loop a table to use field in query
    By jdubp in forum Programming
    Replies: 0
    Last Post: 03-04-2008, 11:48 AM

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