+ Reply to Thread
Results 1 to 6 of 6

VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

    Hi everyone!

    I have a userform in Excel with VBA code that connects to Access database. The code below simply selects certain details from database & populate the label objects once the userID and password matched.

    But what I also want is to just simply pop-up a message box if the userID & password supplied in the userform DID NOT match. I can't seem to find a solution to this simple action that I need. I'm hoping somebody could help.

    Thanks,
    hydz1213


    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

    You need to check if the recordset is empty, so if BOF = TRUE and EOF = TRUE then the password is incorrect since there are no rows returned.

    P.S I really hope you aren't storing passwords in plain text

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

    Hi Kyle123,

    Thank you so much for your response. The passwords are actually alphanumeric characters which I hope is not the reason why I can't still seem to get this message box to pop-up work.

    I tried revising the code with this, but nothing happens if userID & password is not a match.

    Please Login or Register  to view this content.
    Please correct me! I'm really new in ADODB.

    Thanks again,
    hydz1213

  4. #4
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

    With this code, it now does work! Message box pops-up when userID & password is not a match. However, if found a match, it DOES NOT retrieve data anymore!

    I'm really confused!

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

    You need to check whether the recordset is empty BEFORE trying to loop through it:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA/ADODB: to pop-up message box if userID & password in Access database didn't match

    Hi Kyle123

    Sorry for very late reply. But your code worked already!!!

    Thank you so much for your clarification. I'm still learning the ADODB syntax.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1