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

Exporting Data

Status
Not open for further replies.

Robyne

Technical User
Mar 2, 2002
70
US
I'm not sure I'm in the right Forum, but this is what I need to do. I have a database with multiple tables. I need to pick and choose fields from several of these tables and get a Fixed Length ASCII file without a field delimiter. Is this possible? I don't see where to go to select, say fields1 and 2 from this table and fields 3 and 4 from that table. I tried using a report then exporting, but I have to accomodate 255 fields and I don't think my field lengths were correct in the output file. Thanks!

Robyne-
 
I think the best bet is to build a query from an SQL string and export that.

Code:
Dim qdf As QueryDef

strSQL = "Select ID, " & ListOfFields & " From Table1"
If IsNull(DLookup("[Name]", "MSysObjects", "[Name]='qryQuery'")) Then
    Set qdf = CurrentDb.CreateQueryDef("qryQuery", strSQL)
Else
   Set qdf = CurrentDb.QueryDefs("qryQuery")
   qdf.SQL = strSQL
End If
        
DoCmd.TransferText acExportFixed, , "qryQuery", "Text.txt"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top