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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

space padding between two fields.

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
Hello,

I have the following code;

SELECT ([Lap ID])&" "& ([Last Update]) AS Expr1
FROM Laptops;

What is happening is that the list is not lined up correctly.

Ex;

07AJ 4/30/2008
0111 4/30/2008

I'm trying to line them up. The max characters for the [Lap ID] field is 3. But I want the length to always be fixed by let's say 5 spaces. I thought I could use the Chr(9) function. Where (9) is a horizontal tab non printable character. I tried to do this;

SELECT ([Lap ID])&+chr(9)+& ([Last Update]) AS Expr1
FROM Laptops;

But I got an error. I couldn't find my answer using the MS Help or on line help for Access. Any asistance would be appreciated.
 
Code:
SELECT ([Lap ID])& Space(5-len([lap id ])) & [Last Update] AS Expr1
FROM Laptops;
 
pwise's solution should work but note that they still may not line up unless you use a non-proportional font like Courier New.

This
Code:
SELECT ([Lap ID])&+chr(9)+& ([Last Update]) AS Expr1
FROM Laptops;
will raise an error because of the "+" signs. Try
Code:
SELECT ([Lap ID]) & chr(9) & ([Last Update]) AS Expr1
FROM Laptops;
 
If you are ultimately trying to output tabular data for presentation purposes, for example in an .asp file on a Web site, you could select your information and then write it into a table which would line things up nicely.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top