problem with my code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hanlon

    problem with my code

    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.cbous ername) 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.txtpa ssword) 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("Passwo rd", "usyspasswo rd", "[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

    intLogonAttempt s = intLogonAttempt s + 1
    If intLogonAttempt s > 3 Then
    MsgBox "You do not have access to this database.Please contact admin.",
    vbCritical, "Restricted Access!"
    Application.Qui t
    End If





    Exit_cmdlogin_C lick:
    Exit Sub

    End Sub






  • Larry  Linson

    #2
    Re: problem with my code

    "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" <mhanlon@person ainternet.com> wrote in message
    news:vtus6n9q9s adb3@corp.super news.com...[color=blue]
    > 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.cbous ername) 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.txtpa ssword) 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("Passwo rd", "usyspasswo rd", "[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
    >
    > intLogonAttempt s = intLogonAttempt s + 1
    > If intLogonAttempt s > 3 Then
    > MsgBox "You do not have access to this database.Please contact admin.",
    > vbCritical, "Restricted Access!"
    > Application.Qui t
    > End If
    >
    >
    >
    >
    >
    > Exit_cmdlogin_C lick:
    > Exit Sub
    >
    > End Sub
    >
    >
    >
    >
    >
    >[/color]


    Comment

    • Tony Toews

      #3
      Re: problem with my code

      "Larry Linson" <bouncer@localh ost.not> wrote:
      [color=blue]
      >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.[/color]

      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.microso ft.com you will likely want to ask your question in the
      m.p.access.secu rity newsgroup.

      ACC: Microsoft Access Security FAQ Available in Download Center

      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)


      ACC2000: Overview of How to Secure a Microsoft Access Database


      ACC2002: Overview of How to Secure a Microsoft Access DB


      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

      Comment

      • Larry  Linson

        #4
        Re: problem with my code

        "U N Me" <unme@together. com> wrote in message
        news:FCJU9DI337 972.0310648148@ 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 <mgg@uiuc.edu >, please
        contact <abuse@uiuc.edu >
        Mail-To-News-Contact: abuse@dizum.com


        Comment

        Working...