Jeff G
Jeff G

Reputation: 4677

Microsoft Access 2013 Validation Rule with Literal Asterix

How do I add a validation rule to a column in MS Access 2013, where the column value can either be "A" or "*"? When I try to add the validation rule:

"A" Or "*"

The MS Access Expression Builder changes it to:

"A" Or Like "*"

Which doesn't constrain the value at all. I have tried the following, and all are modified by the expression builder to include the word "Like":

"A" Or "*"
'A' Or '*'
"A" Or "\*"

I have been able to trick Access into treating my text as a string literal using the following kludge:

"A" Or UCase("*")

But that seems incredibly cumbersome to do something so simple. Does anyone know the "clean" way to add such a validation rule to Access 2013?

Upvotes: 0

Views: 97

Answers (1)

Jeff G
Jeff G

Reputation: 4677

Access supports an "In" operator, which would allow for the following validation rule syntax:

In("A","*")

If the column also supports null values, then simply add that exception before the "In" operator:

Is Null Or In("A", "*")

Upvotes: 1

Related Questions