Combo Box and validation rule

  • Thread starter khashid via AccessMonster.com
  • Start date
K

khashid via AccessMonster.com

Hi, I am facing a problem. I got a combo box "Card Type" having 3 options to
chose from. I got another field " Card No".

I have two things in my mind whichever is possible:
1st:

If user choses Card Type : 1
Card No Field size changes to 16

If user choses Card Type : 2
Card No Field size changes to 18

If user choses Card Type : 3
Card No Field size changes to 19

(Card No field will have dashes in one option so i size is including dashes
and should be text)

2nd:

If user choses Card Type : 1
ValidationRule = "????????????????" (should be 16 digits including dashes am
not sure if i should use ? or some other symbol
ValidationText = "Card should be 16 digits long "

If user choses Card Type : 2
ValidationRule = "????????????????" (should be 16 digits including dashes am
not sure if i should use ? or some other symbol
ValidationText = "Card should be 18 digits long "

If user choses Card Type : 3
ValidationRule = "????????????????" (should be 16 digits including dashes am
not sure if i should use ? or some other symbol
ValidationText = "Card should be 19 digits long "
 
M

Michel Walsh

At table design level?

Since the validation of one field depends on the value of another field,
same row, that would be a table validation rule, not a field validation
rule.


(CardType=1) IMP CardNo LIKE "????????????????"
AND
(CardType=2) IMP CardNo LIKE "??????????????????"
AND
(CardType=3) IMP CardNo LIKE "???????????????????"


should do.

IMP is a not an often used logical operator, but it is quite useful here. If
the left argument is true, the operator to return the second argument; if
the left argument is false, the operator returns true, independently of what
is the second argument.

table of truth----------IMP------------------
x IMP y; y=true y=false y is null
x=true TRUE FALSE NULL
x=false TRUE TRUE TRUE
x is null TRUE NULL NULL



Vanderghast, Access MVP

=======================
Trick to fill the table of truth when NULL is involved: first, fill the
table slots under the TRUE and FALSE arguments (line and columns). Next, to
get the result in a slot which is about an argument being NULL: if the line
(column) has only one value, the null argument related slot get the same
value, else, the slot get NULL.


x IMP y; y=true y=false y is null
x=true TRUE FALSE r1
x=false TRUE TRUE r2


so r2 becomes TRUE, because the second line has two true, while r1 becomes
NULL, because we have and a true, and a false.


x IMP y; y=true y=false y is null
x=true TRUE FALSE NULL
x=false TRUE TRUE TRUE
x is null r3 r4 r5


r3 becomes TRUE (two true-s in the first column), r4 become NULL, and r5
(line or column) becomes NULL.
 
M

Michel Walsh

better trying:

((CardType=1) IMP CardNo LIKE "????????????????")
AND
((CardType=2) IMP CardNo LIKE "??????????????????")
AND
((CardType=3) IMP CardNo LIKE "???????????????????")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top