UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Create Login Form    
 
   
mnazera
post Jan 28 2011, 08:08 AM
Post #1

New Member
Posts: 18



I hope anyone help me, how to create Login Form for multiple user in Access ?

thank
Go to the top of the page
 
+
Roger_Carlson
post Jan 28 2011, 08:51 AM
Post #2

UtterAccess VIP
Posts: 2,337
From: West Michigan



If you are referring to the built-in security in Access 2003 and before, you should read the Microsoft Secuity FAQ.

The built-in security is no longer available in Access 2007 format databases (accdb), in which case, you'd need to build your own.

Try these links:

http://www.databasedev.co.UK/login.html
http://www.access.qbuilt.com/html/custom_login.html

These should get you started.
Go to the top of the page
 
+
jhcarrell
post Jan 28 2011, 09:29 AM
Post #3

UtterAccess Veteran
Posts: 481
From: Birmingham, Alabama



If you're using 2007+, here is a link to a wiki article on the subject. Click Here

There are also several examples of different methods for creating user logins here in the forums that may be found by performing a search.

Hope that helps.
Go to the top of the page
 
+
mnazera
post Jan 28 2011, 10:47 PM
Post #4

New Member
Posts: 18



I tried copy VB codes for login form from http://www.databased...o.UK/login.html :



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

lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmSplash_Screen"

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 admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub

I found error "Can't find project or library" for "lngMyEmpID", and I was tried to replace this code with "lngEmpID" by delete of "My", but still error if I run in Microsoft Access XP, but while I run in Access 2010, it working properly, my file Access saved as Access 2000.

Can anyone help me, pls

Thank
Go to the top of the page
 
+
Tiesto_X
post Jan 29 2011, 06:17 PM
Post #5

UtterAccess Veteran
Posts: 330



Hi.

1st. Create two unbound text boxes.
1. Username
2. Password

2nd. Create two buttons:
1. cmdOK
2. cmdCancel

3th. Add this code to OnClick [Event Procedure]
CODE
Private Sub cmdOK_Click()

Dim rs As Recordset
Dim strSQL As String
Dim strPassword As String
Dim strUserName As String

On Error Resume Next

strUserName = Username.Value

strPassword = Password.Value

    Set db = CurrentDb
    strSQL = "SELECT password FROM sUser WHERE username='" & strUserName & "'"
    Set rs = db.OpenRecordset(strSQL)
    If rs.RecordCount > 0 Then
        If rs.Fields(0) <> strPassword Then
            msgbox "You typed wrong username or password. Try again.", vbOKOnly, "Warning!"
        Else
            Me.Visible = False
            DoCmd.OpenForm "FORM NAME OR SWITCHBOARD", acNormal, , , , acDialog
        End If
    Else
        msgbox "You typed wrong username or password. Try again.", vbOKCancel, "Warning!"
        Username.SetFocus
    End If
End Sub


4th. Add to General Decralations
CODE
Public strUserName As String


5th. Add on Form_OnLoad:
CODE
Private Sub Form_Load()
Username.SetFocus
Username.Value = ""
Password.Value = ""
End Sub


Put some nice background with key picture and enjoy. <
Go to the top of the page
 
+
Tiesto_X
post Jan 30 2011, 02:58 AM
Post #6

UtterAccess Veteran
Posts: 330



Oh I forgot something.

6th. Create Table sUser
1. ID [Autonumber]
2. Username [Text]
3. Password [Text]

Put some username and password.

Thats it.
Go to the top of the page
 
+
mnazera
post Feb 1 2011, 06:16 AM
Post #7

New Member
Posts: 18



Ok, thank very much
Go to the top of the page
 
+
Miduhath
post May 17 2012, 10:17 AM
Post #8

New Member
Posts: 1



Hey man. thanks for the code. it is really helpful. but i have a problem. i kinda get what the code says. but i dont get the below parts. can u please explain it to me (What it means)
- what is a record set
- what does "Set db = CurrentDb
strSQL = "SELECT password FROM sUser WHERE username='" & strUserName & "'"
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
If rs.Fields(0) <> strPassword" this mean?
- what does rs.fields(0) mean

Thanks you in advance thanks.gif
and could u reply ASAP
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 31st July 2014 - 10:32 AM

Tag cloud: