View Full Version : Setting a format in a field in a union query


Nats
06-21-2007, 04:30 AM
Hi everyone,

Please would someone be able to help me?
I have created a union query however, one of the columns, has not picked up the same format as it has in the tables. As in the tables it has this format
'00000'.

Please woud you be able to advise me how I can change the format on one of the 'columns' in my union query. As one column is 'numbers' and the other is 'text'. I need to change the number column so the format is '00000'.

Thank you in advance for your help.

Nats

RuralGuy
06-21-2007, 06:22 AM
Have you tried Format([YourField],"00000")?

Nats
06-21-2007, 06:37 AM
:) Thanks for your reply. I haven't tried that but where would I put that in my SQL Statement?

you know when you do:

SELECT [column name], [2nd column name]
FROM [table name]
UNION
SELECT [column name], [2nd column name]
FROM [2nd table name]


Its the first column that I need to change the format to '00000' as this is how the format is in the table. So where in the above SQL statement would I put your suggestion?

Thank you for you help so far, Its really appreciated.

Nats

Nats
06-21-2007, 07:03 AM
I have just tried putting in like this but comes up syntax error.

SELECT ([Column name]"00000"), [column name 2]
FROM [table name]
UNION
SELECT ([column name]"00000"), [column name 2]
FROM [table name]

I also tried just using this ' symbol in place of the ".

Do you have any other suggestions or can anyone else help at all?

Thanks in advance

neileg
06-21-2007, 07:44 AM
SELECT Format([YourField],"00000") AS NewField

Nats
06-21-2007, 07:47 AM
Thanks Neil - i am going to try that now.

However where in the SQL statement would I put that. you know it the one I have set out in my message you replied to .

Thanks again.

Nats