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

Chi Is CurrentAsked:
Who is Participating?
Guy Hengel [angelIII / a3]Connect With a Mentor 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

Guy Hengel [angelIII / a3]Billing EngineerCommented:
could you please describe in plain english what the VIN code 39 is ?
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      $      /      +      %

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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

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

All Courses

From novice to tech pro — start learning today.