Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / July 2004

Tip: Looking for answers? Try searching our database.

Validation rule

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ashley - 29 Jul 2004 21:57 GMT
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
ASP.Confused - 29 Jul 2004 22:17 GMT
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

> 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
[quoted text clipped - 6 lines]
> Thanks
> Ashley
ASP.Confused - 29 Jul 2004 22:23 GMT
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.

> Well, if you're adding it through a macro, here is some sample code (should
> work :-))
[quoted text clipped - 20 lines]
> > Thanks
> > Ashley
Ernie - 30 Jul 2004 06:33 GMT
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
[quoted text clipped - 28 lines]
>
>.
ASP.Confused - 30 Jul 2004 13:28 GMT
Expanding on Ernie's method, here is this:

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

> try something like:
>
[quoted text clipped - 49 lines]
> >
> >.
Jeff Boyce - 30 Jul 2004 12:54 GMT
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.

Signature

Good luck

Jeff Boyce
<Access MVP

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.