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

Access 2000 and textfiles

Status
Not open for further replies.

THOMASNG

Technical User
May 3, 2002
254
US
In our product, the special-purpose computer needs two
textfiles to run properly. The data will already stored in
an Access 2000 database, and will change one to three times each week.
I would like to use the existing database to create these
files, however, the database has eight fields, but I only need to use one or two of them to create these textfiles.
How do I mask out these unwanted fields?
 
Just create queries to get the data you need and output them to the text files:

Code:
Sub Output2Fields()

  Dim rst As Recordset
  
  Set rst = CurrentDb().OpenRecordset("2FieldsQuery")
  
  If Not rst.RecordCount = 0 Then
  
    Open "C:\Test2.txt" For Output As #1
    
    With rst
      While Not .EOF
        Print #1, .Fields(0) & "," & .Fields(1)
        .MoveNext
      Wend
    End With
    
    Close #1
    
  End If
End Sub
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Yes, using queries did the trick!
However, in addition to the data taken from the database,
I need to add a two-line to each textfile, for the special-purpose computer to accept them. The two-line headers are
static, i.e., they won't vary.

Thomas Ng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top