password validation in Access

Dear experts,
I need to validate that a password meets the following criteria - any help is appreciated!
=> Must be at least 8 characters, and include at least one of the following: numeric character, uppercase, non-alpha or punctuation (where not limited by the system)

Thank you -
terpsichoreAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
you can use Regular expression or VBscript, but here is a simple VBA code
Function IsPasswordValid(pw As String)
 Dim j As Integer, bNum As Boolean, bUCase As Boolean, bNonAlpha As Boolean
 Dim strNonAlpha As String
 strNonAlpha = "!@#$%^&*"
 If Len(pw) < 8 Then IsPasswordValid = False: Exit Function
 
 For j = 1 To Len(pw)
    If IsNumeric(Mid(pw, j, 1)) Then
        bNum = True
    ElseIf InStr(strNonAlpha, Mid(pw, j, 1)) Then
        bNonAlpha = True
    ElseIf Asc(Mid(pw, j, 1)) > 64 And Asc(Mid(pw, j, 1)) < 91 Then
        bUCase = True
    End If
 Next
IsPasswordValid = (bNum + bNonAlpha + bUCase) * -1 = 3

End Function

Open in new window


the code may need correction depending on your condition about the allowable non-alpha characters, which you can include in the string "strNonAlpha" or you can add another ElseIf condition
post back if you need more revision
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
terpsichoreAuthor Commented:
works perfectly - thank you.
out of curiosity - I was choking on this line using Regexp, any ideas what's wrong with this?
   If Len(TestPw) < 8 Or RegExpFind(TestPw, "[^a-zA-Z0-9\!\@\#\$\%\^\&\*\_\+]", 1, True) <> "" Or RegExpFind(TestPw, "\d", 1) = "" Or RegExpFind(TestPw, "[A-Z]", 1, True) = "" Or RegExpFind(TestPw, "\!\@\#\$\%\^\&\*\_\+", 1, True) = "" Then
'        checkPwd = "Please fix: Password must be at least 8 characters, and include at least one of the following: numeric character, uppercase, and a non-alphanumeric character."

RegExpFind is a function by Patrick Mathews you may be familiar with... the fourth parameter = case-sensitive
0
Dana TimmermanCommented:
I put this code in, but it did not do anything? I must have done something wrong
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.