File Flat

File Flat
Newbie trying to make a flat file from Access Database?

Now that I’ve been able to make a database, and queries and forms, my employer wants me to make a “flat file” of the data to pass to other systems. Now, of course the export feature works, but I’m trying to do it in a VBA procedure so that editting can be done. Anyone have a simple database example that has this? We’ll email to see if we both understand each other. Thanks.
Just to tell you how stupid I am, it would have helped IF I PUT SOME GOD DAM RECORDS IN THE DATBASE. LOL

‘procedure to export data
Public Sub Export(rs As ADODB.Recordset, Optional FileName As String = “Export.csv”, Optional Delimiter As String = “,”)

If rs.EOF Then Exit Sub ‘ nothing to print
Dim Fnum As Integer ‘
Dim strName As String
Dim filePath As String
Dim i As Long
Fnum = FreeFile
filePath = Application.CurrentProject.Path & “”
Open filePath & FileName For Output As Fnum
For i = 0 To rs.Fields.Count – 1
strName = strName & rs.Fields(i).Name & “,”
Next i
Print #Fnum, strName
Print #Fnum, rs.GetString(adClipString, , Delimiter, vbCrLf)
Close #Fnum
MsgBox “File exported”

End Sub

‘ ummm yeah I usually don’t give out my code but here its thanksgiving. are you able to understand it?? Good luck

Flat File Databases


You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.