A
A E
Hi,
I'm trying to run a For each statement, I end up in the debugger with
Run-time error '3251' Operation is not supported for this type of object.
What I'm trying to do is to put the Fieldnames in top of the exported file.
This is as far as I've reached:
Dim rsCurr As DAO.Recordset
Dim fldCurr As DAO.Field
Dim intFile As Integer
Dim curTotal As Currency
Dim strFile As String
Dim strOutput As String
Dim varData As Variant
strFile = "C:\Output.txt"
intFile = FreeFile()
sngTotal = 0#
Set dbCurr = CurrentDb()
Set rsCurr = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot,
dbForwardOnly)
If rsCurr.EOF = False Then
Open strFile For Output As #intFile
varData = ""
'"This is the part that doesn't work"
For Each fldCurr In rsCurr
varData = varData & fldCurr.Name & ","
Next fldCurr
Best regards, AE
I'm trying to run a For each statement, I end up in the debugger with
Run-time error '3251' Operation is not supported for this type of object.
What I'm trying to do is to put the Fieldnames in top of the exported file.
This is as far as I've reached:
Dim rsCurr As DAO.Recordset
Dim fldCurr As DAO.Field
Dim intFile As Integer
Dim curTotal As Currency
Dim strFile As String
Dim strOutput As String
Dim varData As Variant
strFile = "C:\Output.txt"
intFile = FreeFile()
sngTotal = 0#
Set dbCurr = CurrentDb()
Set rsCurr = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot,
dbForwardOnly)
If rsCurr.EOF = False Then
Open strFile For Output As #intFile
varData = ""
'"This is the part that doesn't work"
For Each fldCurr In rsCurr
varData = varData & fldCurr.Name & ","
Next fldCurr
Best regards, AE