[AccessD] 2 qstions: Create table using UNION; Export to flatfile

Stuart McLachlan stuart at lexacorp.com.pg
Tue Oct 26 04:26:41 CDT 2004


On 26 Oct 2004 at 1:46, S D wrote:

> Hi group,
>  
> I've got 2 questions.
> First question:
> I need to create a table using a UNION query. How can I do this? 
>  

Something like:

SELECT  INTO newtable
FROM
(Select * from table1
UNION
Select * from table2);

> Second question:
> I need to create a TAB-delimited flatfile using the table created above. How do I do that?
>  

I prefer to build my own text files using VBA. In DAO, something like:

Function BuildCSV() as Long
Dim rs as DAO.Recordset
Set rs = CurrentDb.OpenRecordset("NewTable")
Open "myFile.CSV" for Output As #1
While not rs.eof
    Print #1, rs(0) & chr$(9) & rs(1) & chr$(9) & rs(2).....
    rs.MoveNext
Wend
rs.Close
Close #1
End Function

You can mess around with the "Print #" line to format your output exactly 
the way you want it.



-- 
Stuart





More information about the AccessD mailing list