Hi! I tried this code to export fields from a SELECT but two lines doesn't work.
Public Sub ToTextFile()
Dim intFileNum As Integer
Dim strFileName As String
Dim strText As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
intFileNum = FreeFile
strFileName = App.Path & "\" & Month(Date) & Day(Date) & Year(Date) & ".Log"
On Error Resume Next
Set db = CurrentDb
Set rst = db.OpenRecordset("Select [Name] From [Users]")
rst.MoveFirst
If Err <> 0 Then Exit Sub 'No Records
Do While Not rst.EOF
strText = strText & IIf(strText <> "", "+", "") & rst![Name]
rst.MoveNext
Loop
Open strFileName For Output As intFileNum
Print #intFileNum, strText
Close #intFileNum
Exit Sub
The line: If Err <> 0 Then Exit Sub 'No Records
and the line: strText = strText & IIf(strText <> "", "+", "") & rst![Name]
doesn't work. I use Access 2000. Any help would be appreciated!
Public Sub ToTextFile()
Dim intFileNum As Integer
Dim strFileName As String
Dim strText As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
intFileNum = FreeFile
strFileName = App.Path & "\" & Month(Date) & Day(Date) & Year(Date) & ".Log"
On Error Resume Next
Set db = CurrentDb
Set rst = db.OpenRecordset("Select [Name] From [Users]")
rst.MoveFirst
If Err <> 0 Then Exit Sub 'No Records
Do While Not rst.EOF
strText = strText & IIf(strText <> "", "+", "") & rst![Name]
rst.MoveNext
Loop
Open strFileName For Output As intFileNum
Print #intFileNum, strText
Close #intFileNum
Exit Sub
The line: If Err <> 0 Then Exit Sub 'No Records
and the line: strText = strText & IIf(strText <> "", "+", "") & rst![Name]
doesn't work. I use Access 2000. Any help would be appreciated!