2 Examples of pattern matching

In Access and other database applications (such as GIS), data entry often requires some form of validation. Some validation can be done just by setting the correct type of data for a field. For example, in a sales order, the “quantity” column should use a type of “number” instead of “text”. This guarantees some minimal validation that non-numbers cannot be used for data of this field.

However, not all validation can be done with the type of a field. For example, the Canadian postal code has a format of AOA OAO. This means that it has six characters, with letters and digits interleaved. For example, “K1A 0B1” and “X5G 2M9” are both valid postal codes.

Validating such a pattern is not easy. While it can be done with conventional string (text) functions that exist in all implementations of BASIC, the logic requires a bit of coding.