G
Guest
Hello,
I'm using Access 2003. I have query that returns three fields from a table,
all text-based, and adds some extra formatting text. Here is my SQL:
SELECT FOOD_CATEGORY & " - " & Round(LIKE_PERCENT*100,2) & "%" & " - " &
Round(DISLIKE_PERCENT*100,2) & "%"
FROM tbl_Food_Categories;
Here is an example of the query results:
Soda - 60% - 70%
Roll - 12% - 88%
Pepperoni Pizza - 100% - 10%
My question is, how can I format/align the text so that it is like:
Soda - 60% - 70%
Roll - 12% - 88%
Pepperoni Pizza - 100% - 10%
I have tried counting characters, but if you will notice, "Soda" and "Roll"
both have 4 characters, yet they are not the same width (the lower-case L is
a very thin character compared to others), and every character seems to have
a different width, so using the Len() function to determine how man " "s to
put before the first "-" isn't helping. For example, if I did something like:
SELECT FOOD_CATEGORY & String(25-Len(FOOD_CATEGORY)," ") & " - " &
Round(LIKE_PERCENT*100,2) & "%" & " - " & Round(DISLIKE_PERCENT*100,2) & "%"
FROM tbl_MIP_Categories;
Here are the results:
Soda - 60% - 70%
Roll - 12% - 88%
Pepperoni Pizza - 100% - 10%
Any way to align the text in a query result properly?
This data will end up being dumped to 100s of Excel Spreadsheets that will
be distributed without any chance for manual editing in Excel, so I need a
programmatic solution. I am open to formatting in Excel too if that would be
easier than Access.
Any ideas?
Thanks,
Scott
I'm using Access 2003. I have query that returns three fields from a table,
all text-based, and adds some extra formatting text. Here is my SQL:
SELECT FOOD_CATEGORY & " - " & Round(LIKE_PERCENT*100,2) & "%" & " - " &
Round(DISLIKE_PERCENT*100,2) & "%"
FROM tbl_Food_Categories;
Here is an example of the query results:
Soda - 60% - 70%
Roll - 12% - 88%
Pepperoni Pizza - 100% - 10%
My question is, how can I format/align the text so that it is like:
Soda - 60% - 70%
Roll - 12% - 88%
Pepperoni Pizza - 100% - 10%
I have tried counting characters, but if you will notice, "Soda" and "Roll"
both have 4 characters, yet they are not the same width (the lower-case L is
a very thin character compared to others), and every character seems to have
a different width, so using the Len() function to determine how man " "s to
put before the first "-" isn't helping. For example, if I did something like:
SELECT FOOD_CATEGORY & String(25-Len(FOOD_CATEGORY)," ") & " - " &
Round(LIKE_PERCENT*100,2) & "%" & " - " & Round(DISLIKE_PERCENT*100,2) & "%"
FROM tbl_MIP_Categories;
Here are the results:
Soda - 60% - 70%
Roll - 12% - 88%
Pepperoni Pizza - 100% - 10%
Any way to align the text in a query result properly?
This data will end up being dumped to 100s of Excel Spreadsheets that will
be distributed without any chance for manual editing in Excel, so I need a
programmatic solution. I am open to formatting in Excel too if that would be
easier than Access.
Any ideas?
Thanks,
Scott