Validation rule

A

Ashley

I would like a field in my table to have 5 characters. If
the entry have less than 5, a Zero adds to the front of
data.
If enter 345D. It should correct to 0345D.
If entry more than 5 characters, validate text pop-up.
Could someone help me with the "Zero adds to the front of
data"?

Thanks
Ashley
 
A

ASP.Confused

Well, if you're adding it through a macro, here is some sample code (should
work :))

Dim A as string, B as string

A = "345D"
B = String("0", 5 - Len(A)) + A


B now contains the string you need :) If it doesn't work...look up how to
use the String function.


Sincerely,
ASP.Confused
 
A

ASP.Confused

Stupid me....just realized what a "Validation Rule" is...lol. What I gave
you might help you out, but I'm stuck on this question too.
 
E

Ernie

try something like:

Me![MyField] = Right("00000" & [input],5)

I'm not certain of the placement of the quotes but it
should be similar to that.

Me![MyField] is where you want to store it
[input] is what the user typed in

HTH
 
J

Jeff Boyce

Ashley

Why? Are you more concerned about how it looks, or what character string is
stored? You can set the display format to zero-pad, without altering the
stored string.
 
A

ASP.Confused

Expanding on Ernie's method, here is this:

Me![MyField] = String$(5 - Len([input], "0") + [input]




Ernie said:
try something like:

Me![MyField] = Right("00000" & [input],5)

I'm not certain of the placement of the quotes but it
should be similar to that.

Me![MyField] is where you want to store it
[input] is what the user typed in

HTH
-----Original Message-----
Stupid me....just realized what a "Validation Rule" is...lol. What I gave
you might help you out, but I'm stuck on this question too.


sample code
(should work...look up how
to


.
 

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