Text field format fills?

G

Guest

I have a four digit text field that combines letters and numbers. When the
field is all numbers and starts with one or more zeroes it drops the zeros.
Any way to automatically show all four digits on a report? I have done this
with number fields, but unfortunately this needs letters as well.
EX: data table = 123, report = 123, want report to show 0123.

Thank you.
 
A

Allen Browne

1. Open the report in design view.

2. Right-click the text box, and choose Properties.

3. On the Format tab of the Properties box, set the Format property to:
0000
 
G

Guest

This works for me when the Data Type is a number, but it doesn't work for
when the Data Type is Text - should it?

Thanks for your help!!!
 
D

Douglas J Steele

How are you assigning the value to the text field?

If you're using

TextField = NumericField

try

TextField = Format(NumericField, "0000")

or

TextField = Right("0000" & NumericField, 4)
 
A

Allen Browne

If the data type is Text, you could use:
=Format(Val(Nz([MyField], "0")), "0000")
or perhaps
=IIf(Len([MyField]) < 4, String(4 - Len([MyField]), "0"),Null) &
[MyField]

Be sure to change the Name of your text box as well. Access gets confused if
the control has the same name as a field, but is bound to something else.
 

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