Hello!
I have the following VBA code in my Access database, but it keeps complaining on the line: Dim DBS As Database
Any one knows whats wrong?
/Andreas
Private Sub Kommandoknapp0_Click()
sExport "c:\test.txt", "exportfil"
End Sub
Private Function sExport(strFil As String, strFraga As String)
Dim f As Integer
'If Dir(strFil) <> "" Then
' If MsgBox("File exists, overwrite?", vbYesNo + vbQuestion + vbDefaultButton2) = vbNo Then Exit Function
'End If
f = FreeFile
Open strFil For Output As f
Dim DBS As Database, RST As Recordset
Set DBS = CurrentDb
Dim a As Field
Dim strExp As String
Set RST = DBS.OpenRecordset(strFraga)
strExp = ""
'For Each a In RST.Fields
' strExp = strExp & ";" & a.Name
' MsgBox strExp
'Next
'Print #f, Right(strExp, Len(strExp) - 1)
With RST
While Not .EOF
strExp = ""
For Each a In .Fields
strExp = Trim(strExp) & ";" & Trim(a)
'MsgBox strExp
Next
Print #f, Right(strExp, Len(strExp) - 1)
.MoveNext
Wend
End With
Set RST = Nothing
Close f
MsgBox strFil & " klar!"
End Function
I have the following VBA code in my Access database, but it keeps complaining on the line: Dim DBS As Database
Any one knows whats wrong?
/Andreas
Private Sub Kommandoknapp0_Click()
sExport "c:\test.txt", "exportfil"
End Sub
Private Function sExport(strFil As String, strFraga As String)
Dim f As Integer
'If Dir(strFil) <> "" Then
' If MsgBox("File exists, overwrite?", vbYesNo + vbQuestion + vbDefaultButton2) = vbNo Then Exit Function
'End If
f = FreeFile
Open strFil For Output As f
Dim DBS As Database, RST As Recordset
Set DBS = CurrentDb
Dim a As Field
Dim strExp As String
Set RST = DBS.OpenRecordset(strFraga)
strExp = ""
'For Each a In RST.Fields
' strExp = strExp & ";" & a.Name
' MsgBox strExp
'Next
'Print #f, Right(strExp, Len(strExp) - 1)
With RST
While Not .EOF
strExp = ""
For Each a In .Fields
strExp = Trim(strExp) & ";" & Trim(a)
'MsgBox strExp
Next
Print #f, Right(strExp, Len(strExp) - 1)
.MoveNext
Wend
End With
Set RST = Nothing
Close f
MsgBox strFil & " klar!"
End Function