I have this form that searches a table to find a unique username for the user. Let me be clear this is not the primary key, but it is as unique since there can not be more than one in table. What i have been able to do is search the table and retrieve a unique id. Example jason brown comes into your company
Fname = jason
lname = brown
what the code will do is create a user id based on his name. the first typical id will be jbrown, but lets say in this insistance jay brown is taken. will what my code does is it returns jabrown. the problem i am having is that i want to find out how to output the name of the user who has the orginial name. example jabrown is returned for jason brown, now a subform will return the current information:
John Brown, jbrown, table1, and the list could go on. This is where i am stuck, i get an error.
Code:Private Sub btnUserID_Click()On Error GoTo Err_btnUserID_Click' this module is designed to check and return a unique user id.' If a user id is not unique enough it will continue to add characters until either there are no more' letters to count or it finds the unique id desired.Dim strUsername As StringDim booMatch As BooleanDim intChar As IntegerCurrentDb.Execute ("delete * from tbl_temp")booMatch = FalseintChar = 1 'defines how many characters to count forstrUsername = Left(Me!txtFname, intChar) & Me!txtlname 'statement counts the first character in the first name and combines it with the last name. Do While booMatch = False 'boomatch is false since it will asume the record is not present booMatch = IsNull(DLookup("[Username]", "tbl_Users", "[Username] = '" & strUsername & "'")) 'Here since boomatch will be assigned the value of the new username entered. 'if a value is equal then a value of true will be returned If booMatch = False Then ' since no match has been found yet boomatch continues meet criteria Dim firstname As String firstname = "SELECT tbl_users.[fname]" & _ "FROM tbl_users" & _ "WHERE tbl_users.[username]='" & strUsername & "';" CurrentDb.Execute "INSERT INTO tbl_temp (UserFirstName, UserLastname, username) VALUES ('" & firstname & "','" & [txtlname] & "','" & strUsername & "');" intChar = intChar + 1 'Boomatch will add one more character to char to move to the next letter strUsername = Left(Me!txtFname, intChar) & Me!txtlname 'this line will assign a value of username to strusername End If LoopMe.txtUsername = strUsername ' user name is assisgned to our VB text boxIf intChar > 1 Then ' if our word counter is greater than one then the following values are visible Me.txtintchar = intChar Me.txtintchar.Visible = True Me.lbintchar.Visible = True Me.Form2.Visible = True Else 'if it is 1 or less are values will be false Me.lbintchar.Visible = False Me.txtintchar.Visible = False Me.Form2.Visible = FalseEnd IfForms![form1]![Form2].Form.RequeryExit_btnUserID_Click: Exit Sub Err_btnUserID_Click: MsgBox Err.Description Resume Exit_btnUserID_Click End Sub
the highlighted part is where the code does not seem to be working.
I am using 2010 and have a bound field called Policyholder ID number in a table called Policy Information. I would like to calculate how old a person is by using the identity number which is 13 digits (South African ID) and the format is as follows - 7009215069084. Using the first 6 digits this person was born on 21 Sept 1970 and is 42 years old ( Current year of 2012 minus year of birth of 1970 = 42)
How I can include a calculated field so once I type in the identity number the age of the person reflects in a field called Current Age.
I've got a database with an 'address 1' field. Sometimes if it's just a number, excel formats the field as a date. Is there anything to check the field to identify any that are showing as dates as opposed to just normal fields. For example identify all customers who have some variation of dd-mm-yyyy in the address-1 field.
I have a ms access application in Front End and linked tables to sql server 2008 r2 in back end.. every time I open my application the linked tables ask to me for the user and password of the sql server user of the odbc conection. I want to connect to my sql database without login every time the user open the application, I know that can be possible if I start session from vba code...
I have access 2010, I currently have a database in place and operational. What I am wondering is there a way to have a form come up whenever someone opens access and asks for a password and login name. Also I would like to have a 2 tier system. One for Admins and the other for users with limited access.
On my login form, after the user enters the username and password he will have to go manually using the mouse to point at the Enter command button, is it possible to make in a way that after the user enters the password and hit enter proceeds as clicking on the enter command button
I have created a form and modual to capture the current user. The problem is I want to use this infomation to populate a name field in my project form. The modual and form are capturing the login name of tpeter which is correct, but that is not listed name that I want. I need to to associate tpeter with Tim Peter and automaticaly fill in the field. Here is the sql of the field in the project form:
SELECT [tblemployee].[UserId], [tblemployee].[FirstName] & " " & [tblemployee].[LastName] AS Expr1 FROM tblemployee;
Here is the SQL for the Modual:
Option Compare Database Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetCurrentUserName() As String On Error GoTo Err_GetCurrentUserName Dim lpBuff As String * 25 Dim ret As Long, Username As String ret = GetUserName(lpBuff, 25) Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1) GetCurrentUserName = Username & ""
Exit_GetCurrentUserName: Exit Function
Err_GetCurrentUserName: MsgBox Err.Description Resume Exit_GetCurrentUserName End Function
I am still learning Access and coding so I am not sure exactly what everything means yet.
At the moment i have a straight forward login form, were if the username matches to the password the user can log in otherwise they cannot. However i need a login based on access rights. For example if a user A log in he is the administrator and has access to all the tables, to be able to synchronise, add/delete records. However if it is user B they can only read thad inforation form the datasbase. one way i was thinking was about trying to enable and disable certain command buttons on a form. If the users is not admin to disable the add button etc. Has anybody got any other ideas, or do u think this is suitable, or any examples of login screens
I downloaded the attached free login script from somewhere. I configured it so that it points to my website index page after validation.
I've added another field in the database called delegation. An admin delegation would point to a separate index page with admin options allowing the user extra privelleges. I'd like to add a few more lines of code to the check_user.asp page to allow this. Any ideas. I appreciate any help.
I have finished the database application, and now want to make a user login for specific users to run the application (but not to change the internal desgin or data).
How can it be done ? Do I need to split the database first before doing that ? :confused:
Hi.. Been trying to work this out for a little while now. I run an IT workshop for adults with learning issues and although my other office skils are pretty good, my Access skills are a little lacking.
My clients login and out on paper at the moment but I would like to change this to a database type system. The entries would only be name and an automatic one to record actual time of login.
I use Environ("Username") all the time, most frequently for logging who has done something to a record, and have once used it to log people into the database (very basic, much the same as logging who did what to records).
But I was wondering, how feasible is it as a security measure?
I often use it on the main menu of my DBs to give me a different menu (with more advanced options on) than other users.
Is it really that safe to use it as a means to allow people in, or stopping them? I know that obviously you have to stop them getting in other ways (holding shift for example), but assuming all of that is done, in theory, they should only be able to get in if they can log in as an authorised user?
Don't know why it is just struck me - just curious I suppose!
Dear all, I have an application includes one table "info" and two forms "frmlogin" & "frmwelcome". The table "info" contains many columns, two of them are [UserName] and [PassWord]. This table is filled with three records. "frmlogin" form contains two text boxes and one button. I want the user to enter user name and the password in those two text boxes, and when clicking the button, I want the application if that user is registered or no. If yes, he/she will be moved to the "frmwelcom", that display "Welcome [UserName]".
I would like to create a simple login system for my db whereby users differentiated by approvers (people who approve PO forms) or preparers (people who prepare PO forms). The problem is, I do not know where to carry on after creating the form for login. How do I go about doing it? I have seen some samples but I do not really understand the code. Hope that someone will be able to guide me along. Thanks a million.
How can I create a login form in Access to track user's input and the date and time of the input. I need to be able to see who entered specific information into the main form. On my main form I have a button to open a query and send that information to a text file but I would like the information to sent to the text file tab delimited. So far I have only been able to get it to go into the text file with comas to separate the columns. Any ideas on how to do these two things?
Im having a few problems trying to get my login form to function properly. I have created a username and login form. - created 2 unbound text boxes with user and password - created a button that performs the function of calling the username and password based on whether the user enters the password correctly.
When you input the password it continue to prompt you to enter the password when it is the correct password.
Does anyone know how to get around this?
Thanks database attached + code for command below
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then MsgBox "You must enter a User Name.", vbOKOnly, "Required Data" Me.cboEmployee.SetFocus Exit Sub End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then MsgBox "You must enter a Password.", vbOKOnly, "Required Data" Me.txtPassword.SetFocus Exit Sub End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
Else MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!" Me.txtPassword.SetFocus End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1 If intLogonAttempts > 3 Then MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!" Application.Quit End If
I need help with my Video rental store project the problem is that I want a security login method works with the my requirements. The manager has his own form with all the information he need and the other employees has another form.
I used this tutorial http://www.databasedev.co.uk/login.html to make the login form
the employee tables has ID, Password, Access Level
The VB code is like this
Option Compare Database Private intLogonAttempts As Integer Private Sub Form_Open(Cancel As Integer) 'On open set focus to combo box Me.cboEmployeeLogOn.SetFocus End Sub
Private Sub cboEmployeeLogOn_AfterUpdate() 'After selecting user name set focus to password field Me.txtPassword.SetFocus End Sub
Private Sub btnLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployeeLogOn) Or Me.cboEmployeeLogOn = "" Then MsgBox "You must enter a User Name.", vbOKOnly, "Required Data" Me.cboEmployeeLogOn.SetFocus Exit Sub End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then MsgBox "You must enter a Password.", vbOKOnly, "Required Data" Me.txtPassword.SetFocus Exit Sub End If
'Check value of password in tblEmployees to see if this 'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("EmployeePassword", "tblEmployee", "[EmployeeID]=" & Me.cboEmployeeLogOn.Value) Then
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!" Me.txtPassword.SetFocus End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1 If intLogonAttempts > 3 Then MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!" Application.Quit End If
End Sub
I am asking for two things. First I want the Manger go to his form after the login completed and all the other employees go to another form I specify.
Second if there is a way that I show the name of the Employee in the destination form by knowing his ID (passing the ID to the other form).
Before we start - I'm a web dev / sql server grunt. I don't have much experience with access.
We've just performed our PC roll-over and we've moved from Access 2000 to 2003. We have alot of DB's around and some of which have *.mdw's. After the rollover was complete I've gone to the required computers and from ther 'Joined' the work group through the work group administration tool. This allowes the users into the required DB via the correct login.
HOWEVER.... drum roll.
No other databases which don't have any workgroups or logins are displaying the same login from my first DB. Entering the log and pass from the first database will then let you into this unrelated DB.
Does anyone have any ideas on how I can fix this problem?
I really need some help guys. For some reason Access always asks for a login/password even if the database isn't protected. Even when I start a brand new database the prompt comes up. Any ideas as to how to get rid of this.:confused:
i am a new memebr so i want to say hello to everyone, anyways i have created a database in microsoft access and have created a login screen where i have created different users and given them different access rights and permission in using my database, and that all works fine when i log on to the database from where the computer i created all these rights i get a login screen where the user enters the username and pass and then that opens up the database and allows the to view parts of the database which they are allowed to however my problem is this...
it works fine on the computer i created these access using the security (user-level security wizard) feature in microsoft access but when i open the database on a different computer it doesnt bring up a user login screen, meaning it lets anyone access the database etc so what do i do??? please help