Run-time error '93': Invalid pattern string

Hello ~

I'm testing a string to see if it matches code39 character set, described by sPattern, below.

The following code works on another textbox BeforeUpdate event, but is producing an error on a different textbox's BeforeUpdate event.

Me.VendorItemNumber contains a conforming value.

There IS a reason...  Though I'm not finding it.

I'd appreciate your ideas...  

Many Thanks, Jacob


'Does the VIN conform to code39?
        sPattern = "*[!0-9A-Z./+$%- ]*"
        If (Me.VendorItemNumber) Like sPattern Then 'NOT WITHIN CODE39 SYMBOLOGY
                MsgBox "You have entered an INVALID CHARACTER in this field." & vbCrLf & "Vendor Item Numbers must conform to Code39 symbology.", vbCritical, "Invalid Character!"
                Cancel = True
                Exit Sub
        End If

Open in new window

LVL 2
Chi Is CurrentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
could you please describe in plain english what the VIN code 39 is ?
0
Chi Is CurrentAuthor Commented:
Thank you for your reply, angelIII!

The VIN is my note for 'Vendor Invoice Number'

code39 is a barcode symbology limited to the following character set:

Code 39 Character Values:
0      1      2      3      4      5      6      7      8      9      A      B      C      D      E      F      G      H      I      J      K      L      M      N      O      P      Q      R      S      T      U      V      W      X      Y      Z      -      .      space      $      /      +      %

0
Chi Is CurrentAuthor Commented:
I'd like to test the string entered to be certain it does not contain any characters that are not in this set.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
I see now. the "-" inside the string is the problem. move that to the end
sPattern = "*[!0-9A-Z./+$% -]*"

Open in new window

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
Chi Is CurrentAuthor Commented:
That's it!!!!!!  Thank you!!!!!!

Jacob
0
Chi Is CurrentAuthor Commented:
Now that the thrill of getting this working has settled in a little, could you explain WHY the space character needs to preceed the hyphen?

Thanks ~ Jacob
0
Chi Is CurrentAuthor Commented:
...At the end, it is not interpreted as meaning from % to SPACE, which doesn't follow....
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, exactly :)
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.