How to force fields to have a specific lengh

M

Marco

Hi.

I need to merge several fields in a query and the fields that I have to
merge must have a specific lengh even if data that is in the field has not
that lengh.

Imagine:

Field1 must be the size of 20 chars but the data that is into has only 10
chars. When I'll merge this fiels in a query the size gonna be 10 instead of
20.

I have on the field size on table the lengh of 20 chars.

How can I force to to have the 20 chars?

Regards,
Marco
 
J

John Spencer

Try an expression like the following for each of the fields involved.


Left([YourtableName].[YourFieldName] & Space(20),20) as YourFieldName



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
J

Jerry Whittle

Put something like this in a query. The String function will pad out to 20
characters with spaces. Just make sure that Field1 doesn't have any records
of over 20 characters as String doesn't work with negative numbers.

WithSpaces: Field1 & String(20-Len(Field1)," ")
 

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