473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Automate username when making account

rcollins
234 100+
What I need to do is to have the login name box create the user name from the name inputted. I would like to have it create f initial l name except when that is already used, then I would like f initial m initial l name. How is this done?
Nov 18 '08 #1
8 1540
ADezii
8,834 Expert 8TB
I am a little confused on tour request, RCollins. Are you requesting to dynamically create a User Name based on a Name that is entered into a Login Form of some kind? This is provided, of course, if the User does not already exist. If this is so, what is the logic behind this approach?
Nov 18 '08 #2
rcollins
234 100+
I have an old dos program we use now, I am trying to replace this with an access database. The form is simple.
Employee Code
LastName
FirstName
MI
Job Title
UserID
UserPassword
When the lady inputs new info, after she gets the LastName FirstName MI entered I want the UserID to be populated with FI LastName automatically, Unless that is already used. Then I want it to put FI MI LastName so there is a difference.
Nov 18 '08 #3
ADezii
8,834 Expert 8TB
I have an old dos program we use now, I am trying to replace this with an access database. The form is simple.
Employee Code
LastName
FirstName
MI
Job Title
UserID
UserPassword
When the lady inputs new info, after she gets the LastName FirstName MI entered I want the UserID to be populated with FI LastName automatically, Unless that is already used. Then I want it to put FI MI LastName so there is a difference.
  1. I'll assume your Data is stored in a Table named tblDOS, simply replace with your own Table Name in Line #18.
  2. I'll also assume that you require all 3 values, namely, the First, Last Name, and MI.
  3. Copy and Paste the following Sub-Routine into the General Declaratiosn of your 'Form's' Class Module:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub PopulateUserID()
    2. Dim strFI As String             'First Initial
    3. Dim strMI As String             'Middle Initial
    4. Dim strLN As String             'Last Name
    5.  
    6. 'I'll assume you require all 3 entries
    7. If IsNull(Me![LastName]) Or IsNull(Me![FirstName]) Or IsNull(Me![MI]) Then Exit Sub
    8.  
    9. 'If you get here, a Last, First Name, and MI have been entered
    10. strFI = Left$(Me![FirstName], 1)
    11. strMI = Me![MI]         'Should check for a '.'
    12. strLN = Me![LastName]
    13.  
    14. 'Debyug code
    15. 'Debug.Print strFI & " ==> " & strMI & " ==> " & strLN
    16.  
    17. 'Does First Initial/Last Name already exist in UserID?
    18. If DCount("*", "tblDOS", "Left([UserID], 1) = '" & _
    19.    strFI & "' And Mid([UserID], 2) = '" & strLN & "'") > 0 Then     'Yep
    20.   Me![UserID] = strFI & strMI & strLN
    21. Else        'Combination does not exist, ergo
    22.   Me![UserID] = strFI & strLN
    23. End If
    24. End Sub
  4. In the AfterUpdate() Event of the [FirstName], [LastName], and [MI] Fields, Copy and Paste this single line of code:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub FirstName_BeforeUpdate(Cancel As Integer)
    2.   Call PopulateUserID
    3. End Sub
    Expand|Select|Wrap|Line Numbers
    1. Private Sub LastName_AfterUpdate()
    2.   Call PopulateUserID
    3. End Sub
    Expand|Select|Wrap|Line Numbers
    1. Private Sub MI_BeforeUpdate(Cancel As Integer)
    2.   Call PopulateUserID
    3. End Sub
  5. If you have trouble understanding the logic, let me know and I'll explain.
  6. Be advised that this code in not foolproof, since it does not check for the possibility of duplicate FI/MI/LastName entries in UserID. To avoid this possibility, simply Index this Field with No Duplicates allowed, or expand the code.
Nov 18 '08 #4
rcollins
234 100+
I get an error. I changed everything to meet what I had, heres the code
Expand|Select|Wrap|Line Numbers
  1. Private Sub PopulateUserID()
  2. Dim strFI As String             'First Initial
  3. Dim strMI As String             'Middle Initial
  4. Dim strLN As String             'Last Name
  5.  
  6. 'I'll assume you require all 3 entries
  7. If IsNull(Me![LNAME]) Or IsNull(Me![FNAME]) Or IsNull(Me![MI]) Then Exit Sub
  8.  
  9. 'If you get here, a Last, First Name, and MI have been entered
  10. strFI = Left$(Me![FNAME], 1)
  11. strMI = Me![MI]         'Should check for a '.'
  12. strLN = Me![LNAME]
  13.  
  14. 'Debyug code
  15. 'Debug.Print strFI & " ==> " & strMI & " ==> " & strLN
  16.  
  17. 'Does First Initial/Last Name already exist in UserID?
  18. If DCount("*", "EMPLOYEE", "Left([USERID], 1) = '" & _
  19.    strFI & "' And Mid([USERID], 2) = '" & strLN & "'") > 0 Then     'Yep
  20.   Me![USERID] = strFI & strMI & strLN
  21. Else        'Combination does not exist, ergo
  22.   Me![USERID] = strFI & strLN
  23. End If
  24. End Sub
  25.  
I pasted the line into each last firs and mi

Here is the error that I get
"Employee Database can't find the macro "Call PopulateUserID. the macro doesn't exist, or the macro hasn't been saved."
Whats this?
Nov 20 '08 #5
rcollins
234 100+
got it to work thank you
Nov 20 '08 #6
ADezii
8,834 Expert 8TB
got it to work thank you
You are quite welcome.
Nov 20 '08 #7
rcollins
234 100+
Hey, can I ask how would I make this return in lowercase?
Nov 20 '08 #8
rcollins
234 100+
nevermind, LCase( all the other stuf)
Nov 20 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jach | last post by:
How can I get the domain, username and PC network name (Win 2000 Pro & Win XP Pro PC's) of the current logged on user (logged onto a domain and access an intranet page, Window 2000 server running...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
8
by: Raj Thakkar | last post by:
Hi, I am currenty working on a site for intranet. I have a user control in the header of every page that will be displayed only if people with certain username are surfing the site. These lists...
18
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site...
0
by: mracuraintegra | last post by:
I'm stuck on a pretty big problem, and can't seem to find a solution, so any help would be greatly appreciated! I'm working with the default page generated for remote desktop web clients (in the...
5
by: GregO | last post by:
I am new to ASP and would like to know if anyone has a page that will display username, time, IP TIA - Grego
5
Death Slaught
by: Death Slaught | last post by:
I need to know how to make a username and password login screen for an online game that im making and i need it so i can access that person account and look at their password or edit their account so...
2
by: Jim in Arizona | last post by:
I made up a service that will move files from a folder on the machine that the service is running to a share on another machine. I use a try/catch incase an error is thrown and write that error to...
0
by: =?Utf-8?B?TW9uaXF1ZQ==?= | last post by:
I just reinstalled IIS as I worked with wamp before and yet I didn't find out how to have a php and a asp server working the same time on a computer. (I had to uninstall the IIS to get wamp at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.