Results 1 to 5 of 5
  1. #1
    sschrader1 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    2

    Account ID - Generator

    Is it possible to Query seperate tables, such as Students, and Courses and then create an Account Code by selecting the first 2 characters of the Course Name, the first 4 characters of the student's Last Name, the first 3 characters of the Student's First Name, and lastly the Course Date and creating an Account ID with that information ? Example (TN-SCHRHEA04032012)
    Thank You;


    Scott

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Yes - this is possible.
    Are the Student's First Name and Last name in the same field or are they in different fields?
    You could use a combination of the following functions [Len, Left, Right, Instr . . .] in your query to get the pieces of the various strings to concatenate them.
    If you haven't used these functions in sql before, it can seem difficult, so perhaps get ONE part going first [Eg: the first two characters of the Course Name] and then build on that.

    For instance:
    Code:
    SELECT TableName.ID, TableName.Preference, TableName.Weight, TableName.Description, Left([Preference],3) & "-" & Left([Description],4) AS Code
    FROM ID_Preference_Weight;
    This is a simple example. The part in red is where you would get different characters from different fields and concatenate them with the '&'.
    In the example the first 3 characters of Preference are concatenated with a hyphen and the first 4 characters of Description.
    You can also pull in fields from different tables and use them to create your concatenated AccountID.

    Hope this helps.
    Let us know if you need further help.
    Last edited by Robeen; 04-03-2012 at 02:19 PM. Reason: clarity.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    You can but why bother? Do you want to save this calculated value to table? What if student changes name (women still do that sometimes when they marry/divorce).
    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.

  4. #4
    sschrader1 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    2

    Reply/Question ?

    Thank you for this solution. It works. Only question I have is . . . How do you make all the characters capalitized ?

    Quote Originally Posted by sschrader1 View Post
    Is it possible to Query seperate tables, such as Students, and Courses and then create an Account Code by selecting the first 2 characters of the Course Name, the first 4 characters of the student's Last Name, the first 3 characters of the Student's First Name, and lastly the Course Date and creating an Account ID with that information ? Example (TN-SCHRHEA04032012)
    Thank You;
    Scott

  5. #5
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Try the UCase function.
    Code:
    SELECT TableName.ID, TableName.Preference, TableName.Weight, TableName.Description, UCase(Left([Preference],3)) & "-" & UCase(Left([Description],4)) AS Code
    FROM ID_Preference_Weight;
    SQL not tested . . .

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

Similar Threads

  1. Getting one account from 15,000
    By citygov in forum Programming
    Replies: 4
    Last Post: 10-21-2011, 02:27 PM
  2. Code Generator
    By fpmsi in forum Programming
    Replies: 1
    Last Post: 09-20-2011, 08:46 AM
  3. Bank account catagories
    By broecher in forum Database Design
    Replies: 1
    Last Post: 10-16-2010, 10:21 PM
  4. Sorta Random Serial Number Generator
    By Cuselco in forum Programming
    Replies: 3
    Last Post: 08-27-2010, 12:05 PM
  5. account rights
    By pietje in forum Security
    Replies: 1
    Last Post: 02-05-2009, 12:58 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