Hi everyone,
I hope someone can give me a hand with a problem I'm having. How can check to see what field number I'm in of a recordset and add additional formatting as needed? I am using the following code (found in the forms here) to write the table to a text file but in the for each loop, I need to format each of my 5 fields differently.
My fields all need to be wrapped in " " and I can't figure out how to add that in the For Each line in the code above.
Any help is appreciated
Brad
I hope someone can give me a hand with a problem I'm having. How can check to see what field number I'm in of a recordset and add additional formatting as needed? I am using the following code (found in the forms here) to write the table to a text file but in the for each loop, I need to format each of my 5 fields differently.
Code:
Private Sub exp_2_notepad_Click()
Dim rst As DAO.Recordset
Dim db As DAO.database
Dim fld As DAO.Field
Dim strDelimeter As String
Dim strText As String
Dim blnColumnHeaders As Boolean
Dim FilePartOne As String
Dim mdbpath As String
Set db = CurrentDb
blnColumnHeaders = False
Set rst = db.OpenRecordset("select * from Intranet_Search_Directory")
Open "C:\exportfile.txt" For Output As #1
Do While Not rst.EOF
For Each fld In rst.Fields
strText = strText & fld.Value
Next
rst.MoveNext
Loop
'removes the extra line
strText = Left(strText, Len(strText) - Len(vbNewLine))
Print #1, strText
Close #1
End Sub
My fields all need to be wrapped in " " and I can't figure out how to add that in the For Each line in the code above.
Any help is appreciated
Brad