Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format data using SQL in access

Status
Not open for further replies.

jamie81

Programmer
Aug 28, 2001
12
0
0
US
I created a union query between two tables in MS Access 2000. I have an autonumber field in the original table that is formatted with leading zeros. These zeros do not show up in my sql query results. How can I format to display zeros using a sql query?
 
Hi!

In the field definition use NewFieldName: Format([AutonumberField], "0000000000").
Of course, you can use as many zeros as you want.

hth
Jeff Bridgham
 
What do you mean by field definition? This is my current query:(The PermID field is the autonumber field)

SELECT [Brochure ID],[Brochure Name],[Brochures Detail_PermID] AS [PermID],[Order Date],[Ship Date],[Qty],[Salutation],[LastName],[FirstName],[MiddleName],[Address1],[Address2],[City1],[State1],[Zip1],[Add1Country],[HomePhone1],,[PrimaryAddress]
FROM [FirstAddressBrochuresPendingQuery]


UNION SELECT [Brochure ID],[Brochure Name],[Brochures Detail_PermID] AS [PermID],[Order Date],[Ship Date],[Qty],[Salutation],[LastName],[FirstName],[MiddleName],[AltAddress],[AltAddress2],[City2],[State2],[Zip2],[AltAddCountry],[HomePhone2],[Email],[PrimaryAddress]
FROM [SecondAddressBrochuresPendingQuery];
 
Okay,

If I understand what you have here correctly, replace:

[Brochures Detail_PermID] AS [PermID]

with

Format([Brochures Detail_PermID], "0000000000") AS [PermID]

Again, using however many zeros you want.

hth
Jeff Bridgham
 
It worked perfectly! Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top