Results 1 to 9 of 9
  1. #1
    Welshhobo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    5

    Auto create usernames based on name.

    Hey this is my first time posting here. I used to know Access inside and out but havent used it for years. For a project i'm working on i'm manually entering e-mail addresses, names, and surnames. I would like a username and password automatically generated based on what the corresponding fields' first name and surname is with formatting.



    Example:


    Is there any way i can do this using input masks and validation rules? Would this require a VBA script?

  2. #2
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    Have you tried creating a form that allows you to add records to the table you've showed us, and in this form have a button that when clicked, it fills in the Username and Password fields?

  3. #3
    Welshhobo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    5
    Quote Originally Posted by mrojas View Post
    Have you tried creating a form that allows you to add records to the table you've showed us, and in this form have a button that when clicked, it fills in the Username and Password fields?
    That would require a VBA script though wouldn't it? I've literally forgotten everything i learnt about vba :s

  4. #4
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    Yes, that would require some code, but creating the form should be easy when using a wizard. The code should also be easy, you'll be using, and there are is more than one way to do this, the Left function and the ampersand to concatenate strings.
    Give it try, and then ask for some help.

  5. #5
    Welshhobo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    5
    Alright, i've spent hours now trying to figure out how to do this but short of starting a course or buying a book on VBA i can't remember jack from school. I used to program in C++ alot, but have long forgotten that too. If i write some psuedo-code do you think you could help me out?

    All i need is for a button to generate a username and password. Is there a way to only take the first letter of a string? If so, ill just put (1) after it.




    //declaring variables
    string firstname
    string surname

    firstname == [Text Box "First Name"]
    surname == [Text Box "Surname"]

    Text Box ["Username"] == firstnamesurname"01"
    Text Box ["Password"] == firstname"."surname(1)".01"

    end

  6. #6
    Welshhobo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    5
    Nevermind, worked it out



    Code:
    Private Sub Command35_Click()
    
    Dim strUsername As String, strPasswd As String, strSuffix As String
    
    strSuffix = "01"
    
    strUsername = LCase(Me.FirstName + Me.Surname + strSuffix)
    Me.Username = strUsername
    strPasswd = LCase(Left(Me.FirstName, 1) + "." + Me.Surname + "." + strSuffix)
    Me.Password = strPasswd
    
    End Sub

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, now what are you going to do when the 2nd John Smith shows up?

    strPasswd = LCase(Left(Me.FirstName, 1) + "." + Me.Surname + "." + strSuffix)
    And what about spaces and/or dashes (hyphenated names - De La Cruz) or apostrophes in names (O'Brian)?

  8. #8
    Welshhobo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    5
    Quote Originally Posted by ssanfu View Post
    OK, now what are you going to do when the 2nd John Smith shows up?


    And what about spaces and/or dashes (hyphenated names - De La Cruz) or apostrophes in names (O'Brian)?
    Change it manually

    Theyre fine to be left in

    This is only going to be used once so dont really care about functionality - the auto generate button was just so i could halve the time it took to enter a crap load of raw data

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is only going to be used once so dont really care about functionality - the auto generate button was just so i could halve the time it took to enter a crap load of raw data
    I see, said the blind man as picked up his hammer and saw.

    Good luck with your project....

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

Similar Threads

  1. Replies: 10
    Last Post: 07-19-2013, 02:05 PM
  2. Incorporating multiple usernames or alternate names
    By mpreston14 in forum Database Design
    Replies: 1
    Last Post: 04-30-2013, 01:32 PM
  3. Updating field problem, Usernames
    By joeydeck in forum Access
    Replies: 1
    Last Post: 09-17-2012, 07:11 AM
  4. Create a database to hold usernames and passwords
    By sentinelace in forum Programming
    Replies: 1
    Last Post: 10-25-2010, 07:45 AM
  5. Replies: 0
    Last Post: 12-20-2007, 12:32 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