• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1004
  • Last Modified:

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

0
Chi Is Current
Asked:
Chi Is Current
  • 5
  • 3
1 Solution
 
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
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now