login access is not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rvkcools
    New Member
    • Sep 2013
    • 1

    login access is not working

    Hi,

    when i run the code my second if condition is not checking the table wether user have admin access or not.

    after checking 2nd condition its directly moving to else statement. please help me.


    Code:
    If Me.Text13.Value = DLookup("EMP_PW", "M_EMPINFO", "[EMP_NO]=" & Me.Combo2.Value) Then
        If Me.Combo2.Value = DLookup("emp_no", "m_empinfo", "admin_access" = yes) Then
        DoCmd.OpenForm "UserAccess_Form", acNormal, "", "", acFormAdd, acNormal
         Else
    do something
    Last edited by zmbd; Oct 10 '13, 03:27 PM. Reason: [Rabbit; Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.][z{removed extra line breaks in code}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Slightly alter your code:

    Code:
    '(...partial air code...)
    '(...some things left out...)
    '
    'Two variables as variant to handle null/zero
    Dim varFirstValue As Variant
    Dim varSecondValue As Variant
    '
    '(...some things left out...)
    'Pull your lookups
    varFirstValue = DLookup("EMP_PW", "M_EMPINFO", "[EMP_NO]=" & Me.Combo2.Value)
    varSecondValue = DLookup("emp_no", "m_empinfo", "admin_access" = yes)
    '
    'Now let's see what was returned, personally, I'd put some code in here to check for bad returns; however, for TS... the debug.print will do for now...
    debug.print "FirstValue = " & varFirstValue
    debug.print "SecondValue = " & varSecondValue
    '
    'Now once you know what is being returned by the functions and you have done proper error checking, THEN you can use these values:
    If Me.Text13.Value = varFirstValue Then
        If Me.Combo2.Value = varSecondValue Then
        DoCmd.OpenForm "UserAccess_Form", acNormal, "", "", acFormAdd, acNormal
         Else
    do something
    One should ideally never pull data without checking the returned data FIRST.
    Last edited by zmbd; Oct 10 '13, 03:38 PM.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      You should not be storing passwords in plain text like this. It is a huge security risk.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Rabbit is absolutely correct, and something I was remiss in not mentioning... and there are several helpful insight articles that might help with that issue. One such would be: SHA2 Cryptographic Hash Algorithm for VBA and VBScript
        There are a couple of others in the list too...

        Comment

        Working...