Validate number of digits inputted in a field in an access query

Is there a way to check the number of characters inputted into a field in access by using a query.

For example I have a field that should have a five digit filed inputted.  The field may have leading zeroes.
I am trying to determine those fields which have only four digits inputted which is an error.
 04589  is OK
4589  is not
How can I check for this?
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Data DudeCommented:
The quickest way would be to go to your text box's Properties, find the Input Mask property, and type 00000.

Also, whatever ControlSource this is bound to will have to be in text format, as numeric formats do not allow for trailing zeros.
Jim HornMicrosoft SQL Server Data DudeCommented:
{correction}

The quickest way would be to go to your text box's Properties, find the Input Mask property, and type 00000.

Also, whatever ControlSource this is bound to will have to be in text format, as numeric formats do not allow for leading zeros.
LenaWoodCommented:
You could use the format property of the field in the table and put in 5 zeros:

00000

That will make the field be 5 digits.  If someone entered 4589 then Access would show it as 04589.  This is assuming that your field is a number field.

Does that help you in solving your issue?
Lena
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You could use a query to show you all records that meet your criteria:

SELECT * FROM SomeTable WHERE Len(YourField)=5
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Or, to show those that don't meet your criteria:

SELECT * FROM SomeTable WHERE Len(YourField)<>5

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.