Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Posts
    3

    Exclamation Unanswered: Creating Unique IDs (SORRY-Double post)

    I apologize for not knowing much of the proper terminology. I am a long time computer user... but have never done any programing. I am working on my first database which is more than an address book.

    I am really having a hard time understanding table relationships. I also can't seem to get a grasp on queries. I know that both are CRITICAL.

    My specific question is as follows:
    Let's say I want the following fields in a table called MEMBERS.
    Member ID
    LastName
    FirstName
    PhoneNumber
    Talents
    Etc.

    I can create a form to collect that info. But what I would really like is for the field Member ID to be created using data from the LastName, FirstName, and PhoneNumber fields.

    I can set up my form to even display the unique id that I want, but the id is not entered into the table. That is my problem.

    I want the id to be in this format:
    LLFFNNNNN
    where,
    LL=1st 2 letters of LastName
    FF=1st 2 letters of FirstName
    NNNNN=Last 5 digits of Phone Number

    Like I mentioned, I can use the "Left" and "right" functions to display that info in a form... BUT that ID is not entered into my table.

    I know this is a simple question for most of you.
    Thanks for any help you can provide.
    Scott
    Last edited by Taipei; 12-16-02 at 23:20.

  2. #2
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Creating Unique IDs (SORRY-Double post)

    Hi Scott,

    From your explaination I would assume that the Control Source property has a formula in it. Is this true? If it is ... It will need to be MemberID. This will bind it to the memberid field, hence sending the information to that field ...

    Now to get the actual information into it .... Create the following code

    Sub GeneratePK()

    If LastName <> "" AND FirstName <> "" and PhoneNumber <> "" Then
    MemberID = Left(LastName, 2) & Left(FirstName, 2) & Left(PhoneNumber, 5)
    End If

    End Sub

    Now create code for the AfterUpdate event if the 3 fields .... and the code needs to read
    GeneratePK ...

    To do this... Select LastName. Bring up the properties dialog box, select the event tab, select AfterUpdate and click on ...
    Select Code from the dialog box and the following should display ....

    Private Sub LastName_AfterUpadte()

    End Sub

    Add GeneratePK between the two line ans repeat the process for FisrtName and PhoneNumber fields ...

    Hope this works ...



    Originally posted by Taipei
    I apologize for not knowing much of the proper terminology. I am a long time computer user... but have never done any programing. I am working on my first database which is more than an address book.

    I am really having a hard time understanding table relationships. I also can't seem to get a grasp on queries. I know that both are CRITICAL.

    My specific question is as follows:
    Let's say I want the following fields in a table called MEMBERS.
    Member ID
    LastName
    FirstName
    PhoneNumber
    Talents
    Etc.

    I can create a form to collect that info. But what I would really like is for the field Member ID to be created using data from the LastName, FirstName, and PhoneNumber fields.

    I can set up my form to even display the unique id that I want, but the id is not entered into the table. That is my problem.

    I want the id to be in this format:
    LLFFNNNNN
    where,
    LL=1st 2 letters of LastName
    FF=1st 2 letters of FirstName
    NNNNN=Last 5 digits of Phone Number

    Like I mentioned, I can use the "Left" and "right" functions to display that info in a form... BUT that ID is not entered into my table.

    I know this is a simple question for most of you.
    Thanks for any help you can provide.
    Scott
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

  3. #3
    Join Date
    Dec 2002
    Posts
    3

    Thumbs up

    Mona...
    Thank you!
    Now I can move ahead...
    I am sure my next problem will be posted here soon!
    :-)
    Have a great day
    Scott

Posting Permissions

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