By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,173 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

problem with my code

P: n/a
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


Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"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

"Michael Hanlon" <mh*****@personainternet.com> wrote in message
news:vt************@corp.supernews.com...
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


Nov 12 '05 #2

P: n/a
"Larry Linson" <bo*****@localhost.not> wrote:
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.../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.../q132/1/43.asp

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

ACC2002: Overview of How to Secure a Microsoft Access DB
http://support.microsoft.com/support.../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
Nov 12 '05 #3

P: n/a
"U N Me" <un**@together.com> wrote in message
news:FC**********************@Gilgamesh-Frog.org...

From the message header of the quoted message:

Comments: This message probably did not originate from the above address.
It was automatically remailed by one or more anonymous mail
services.
You should NEVER trust ANY address on Usenet ANYWAYS: use PGP !!!
Get information about complaints from the URL below
X-Remailer-Contact: http://80.65.224.85/POL/ In case my abuse address is
unreachable: It is because it has been flooded by <mg*@uiuc.edu>, please
contact <ab***@uiuc.edu>
Mail-To-News-Contact: ab***@dizum.com
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.