Hi Randy
I saw your solution and i think i understand it.
1 - you delete all the records in the temporary table
2 - Insert the records from the the querys where the
concatenated field is allready built
3 - Order the result by an auto number field.
I have to explain one more thing for you and thank for your
help:
I have to send the result by e-mail ,so order the query by
an autonumber field is not a good way, because i have to
order by a Document number that is part of the concatenated
field of the Detail Table.
The solution you sent to me will be done as a command
click, right?
If it is like that , it gives me error with the fields name
i will give all my structure in order you can understand
better my problem:
Tables Querys Field
---------------------------------------
THeader QryExpCab CabText
TDetail QryExpDet DetText
TFooter QryExpRod Rod Text
The field that is mentioned is a concatenated field of all
the fields of the tables that produces the query
After i have the querys, i use the Union All to obtain the
result in my Query name QryTexto.Then i export the result
to a TXT.File to send by e-mail.
the only problem is that : altough i have my Tdetail well
ordered as i want it, when i make the query to obtain the
DetText field and without any changes , just making a field
as an expression as a result of the concatenation, the
order of the table is changed.
And this i don't understand.
Once again i thank for you help and time and would
appreciate very much your help in order to solve this problem.
I think John gave me a good solution but i didn't
understand quiet clear. However i want ot thank you and see
if there is anything else you might see in order to solve
my problem
Thanks again.
Best regards
Samora
-----Original Message-----
Thanks for your reply.
1 Question:
When i made the query with 1 single field (concatenation
from various fields of table TDetails) they are allready
sorted in the way i want.
So, why doesn't it come out in that way(sorted the way i
want) ?
I tried to make a ORDER as you say, but as the Query only
have 1 field it becomes sorting the records from left to
right. So, i stay with my problem and don't understand why
having a table allready sorted , when i make a query based
on that table it doesn't come out sorted that way.
i want to remember that my query doesn't have any kind of
order.
my Query has the following design:
SELECT QryHEADER.Text1 FROM QryHEADER
UNION ALL
SELECT QryDetail.Text2 FROM QryDetail
UNION ALL
SELECT QRYFooter.Text3 FROM QryFooter;
i think that with this SQL i would have the way i want it.
But it is not working.
If you have another suggestion i would appreciate very much.
Thanks in advance
Best regards
P.S. How do i make a ORDER BY clause with a query like the
one i mentioned with only one field concatenated ??
When you mention to include aditional fields, i have to
have all 3 tables with the others additionals fields, right??
Please , explain that to me.
Thanks again
-----Original Message-----
Hi Samora,
Access (and relational databases in general) don't
guarantee to return
records in a consistent order unless you explicitly sort
them. You'll
need to include an ORDER BY clause in the UNION query.
If you can't get the result you need by sorting on the
concatenated
field, you'll have to include additional fields in the
UNION query.
[snip]
John's suggestion is certainly the best solution. You could, however, if
you wished to use a much less elegant solution, insert the data into a
temporary table that contained an autonumber field.
DoCmd.RunSQL "DELETE FROM TEMP_TABLE"
DoCmd.RunSQL "INSERT INTO TEMP_TABLE SELECT * FROM Qry1"
DoCmd.RunSQL "INSERT INTO TEMP_TABLE SELECT * FROM Qry2"
DoCmd.RunSQL "INSERT INTO TEMP_TABLE SELECT * FROM Qry3"
SELECT * from TEMP_TABLE ORDER BY AutoNumberField
would give you all of the data in the order that you wanted.
Clumsy, but it would work.