Check For Bad Characters In Password

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Check For Bad Characters In Password

Post by burrina »

How and or where should I check for Bad Characters in my Password field? In my table I only have it set to 10 characters.
What characters should or should not be allowed or does that make a difference?
I need to come up with a methodology for this.

Here is what I have so far.

Code: Select all

If (Me.pw) = "*?@?*.?*" Or "*[,;]*" Then
    Call MsgBox("These Characters Are Not Allowed * ? @ , ; Please Correct!", vbExclamation, Application.Name)
        Me.Undo
            End If

User avatar
HansV
Administrator
Posts: 78402
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Check For Bad Characters In Password

Post by HansV »

It's up to you to decide which characters you will or won't allow in a password. For wildcard comparisons, you need to use the keyword like, and a construct such as

... = "*?@?*.?*" Or "*[,;]*"

is not valid. To disallow *?@,; use

Code: Select all

    If Me.pw Like "*[?*,;@]*" Then
It might be a good idea not to allow spaces in a password.

Also, keep in mind when checking a password that Access by default performs case-insensitive string comparisons. To force Access to perform case-sensitive string comparisons, you can change the line

Option Compare Database

at the top of the code module to

Option Compare Binary

This will make ALL string comparisons in that module case-sensitive. Or you can use the StrComp function with the vbBinaryCompare option. See StrComp Function if you want only a specific comparison to be case-sensitive.
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Check For Bad Characters In Password

Post by burrina »

Many Thanks.