problem with my code

  • Thread starter Thread starter Michael Hanlon
  • Start date Start date
M

Michael Hanlon

listed below is the code i have written that is not working any help would
be great if you can show me where i went wrong as i am new to this side.
thanks in advance.

Private Sub cmdlogin_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cbousername) Or Me.cbousername = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbousername.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 usyspassword to see if this
'matches value chosen in combo box

If Me.txtpassword.Value = DLookup("Password", "usyspassword", "[ID]=" &
Me.cbousername.Value) Then

ID = Me.cbousername.Value

'Close logon form and open splash screen
If Me.cbousername.Value = "admin" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 1"
ElseIf passwd = "b" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 2"
ElseIf passwd = "c" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 3"
Else
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 4"
End If

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





Exit_cmdlogin_Click:
Exit Sub

End Sub
 
"Not working" is not much for us to go on. Specific questions stand the best
chance of getting useful answers -- the best questions are "precise and
concise".

What do you expect it to do? What is it doing? What is it not doing that you
expect it to do? Are there error messages? If so, what? If so, what line if
you set the option "Break on all errors"?

Just a comment -- you clearly are trying to implement a "Security Lite",
which is usually an exercise in futility. Even Access' own security can be
broken, but self-implemented security is almost always not only breakable
but easy to break. I'd suggest you download the Security FAQ from
http://www.microsoft.com and give it a good read, more than once -- there's
no "filler" in those 39 pages.

Larry Linson
Microsoft Access MVP
 
Larry Linson said:
I'd suggest you download the Security FAQ from
http://www.microsoft.com and give it a good read, more than once -- there's
no "filler" in those 39 pages.

Larry

Here's my standarb blurb which you are free to copy as you feel with the URLs to save
searching.

After reviewing the following KB articles and searching in the Knowledge Base at
support.microsoft.com you will likely want to ask your question in the
m.p.access.security newsgroup.

ACC: Microsoft Access Security FAQ Available in Download Center
http://support.microsoft.com/support/kb/articles/q165/0/09.asp
It is suggested you reread this FAQ several times. I must admit I never quite
understood it.

ACC: Overview of How to Secure a Microsoft Access Database (A2.0 to A97)
http://support.microsoft.com/support/kb/articles/q132/1/43.asp

ACC2000: Overview of How to Secure a Microsoft Access Database
http://support.microsoft.com/support/kb/articles/Q254/3/72.ASP

ACC2002: Overview of How to Secure a Microsoft Access DB
http://support.microsoft.com/support/kb/articles/Q289/8/85.ASP

Note however there have been isolated postings indicating security has been cracked.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Back
Top