see thread709-492487 (and thread222-660477 but change the SELECT to a SELECT * FROM TheTable) if you want to create a query and insert data to a text file in one action.
Here is what I have so far. I saw something like this in Thread709=492487. From that thread however, I don't see how I would create a .txt file form that.
Dim intCounter As Integer
Dim my_Connection As ADODB.Connection
Dim my_Recordset As ADODB.Recordset
Dim strConnection As String
Dim strSql As String
strSql = "SELECT * FROM ProvidedInfo,ReceivableDocument"
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test\RecDoc.mdb;Persist Security Info=False"
Set my_Connection = New ADODB.Connection
my_Connection.Open strConnection
Set my_Recordset = New ADODB.Recordset
my_Recordset.CursorType = adOpenKeyset
my_Recordset.LockType = adLockOptimistic
my_Recordset.Open strSql, my_Connection, , , adCmdText
Do While Not my_Recordset.EOF
Debug.Print my_Recordset.Fields("tbl_RecDoc".Value
Debug.Print my_Recordset.Fields("tbl_AccNum".Value
Debug.Print my_Recordset.Fields("tbl_DueDate".Value
Debug.Print my_Recordset.Fields("tbl_MonthAmt".Value
Debug.Print my_Recordset.Fields("tbl_Entity".Value
Debug.Print my_Recordset.Fields("tbl_Type".Value
my_Recordset.MoveNext
intCounter = intCounter + 1
Loop
my_Recordset.MoveFirst
my_Recordset.Close
my_Connection.Close
Set my_Recordset = Nothing
Set my_Connection = Nothing
>From that thread however, I don't see how I would create a .txt file form that
in my post, change the *.asc to *.txt if that is what you mean.
Like I said, this is if you want to take data (filtered if desired) from a MDB table and put it directly into a text file.
If you have the data already in a recordset, us the method mentioned by Nickel, or the code in Thread222-660477, adding the field values to the SELECT statement.
Keep it simple...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.