Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim MyDatabase as DAO.Database
Dim MyRecordset as DAO.Recordset
Dim MyRecord() as Variant
Dim intFile As Integer, intField As Integer
Dim strRecord As String
Set MyDatabase = CurrentDb
Set MyRecordset = MyDatabase.OpenRecordset("SELECT * FROM [i]SomeTable[/i];")
intFile = FreeFile
Open "C:\Test.csv" For Output As #intFile
While Not MyRecordset.EOF
MyRecord = MyRecordset.GetRows(1)
For intField = 0 To UBound(arrTest)
Select Case TypeName(arrTest(intField))
Case "Date"
strRecord = strRecord & "#" & Format(arrTest(intField), "mm/dd/yyyy") & "#"
Case "String" 'wrap in double quotes, remove double quotes from text
strRecord = strRecord & Chr(34) & Replace(arrTest(intField), Chr(34), Chr(39)) & Chr(34)
Case Else
strRecord = strRecord & arrTest(intField)
End Select
strRecord = strRecord & ","
Next intField
Print #intFile, strRecord
strRecord = ""
Wend
Close #intFile
MyRecordset.Close
MyDatabase.Close
Dim MyDatabase As DAO.Database
Dim MyRecordset As DAO.Recordset
Dim MyRecord() As Variant
Dim intFile As Integer, intField As Integer
Dim strRecord As String
Set MyDatabase = CurrentDb
Set MyRecordset = MyDatabase.OpenRecordset("SELECT * FROM [i]SomeTable[/i];")
intFile = FreeFile
Open "C:\Test.csv" For Output As #intFile
While Not MyRecordset.EOF
MyRecord = MyRecordset.GetRows(1)
For intField = 0 To UBound(MyRecord)
Select Case TypeName(MyRecord(intField[b], 0[/b]))
Case "Date"
strRecord = strRecord & "#" & Format(MyRecord(intField[b], 0[/b]), "mm/dd/yyyy") & "#"
Case "String" 'wrap in double quotes, remove double quotes from text
strRecord = strRecord & Chr(34) & Replace(MyRecord(intField[b], 0[/b]), Chr(34), Chr(39)) & Chr(34)
Case Else
strRecord = strRecord & MyRecord(intField[b], 0[/b])
End Select
strRecord = strRecord & ","
Next intField
Print #intFile, strRecord
strRecord = ""
Wend
Clean_Up:
Close #intFile
MyRecordset.Close
MyDatabase.Close