Using Access 2010
I need to write a CSV file where the number of fields on each record is not the same, requirement of the program we are feeding.
Below is the code I am having I am getting the error: Run-time error 75: Path/File access error.
Error is happening at “Open fileopen for Output as #1” (line 30)
I’m sure someone will be able answer this in their sleep.
I the file is already created and is blank.
Thanks in advance.
I need to write a CSV file where the number of fields on each record is not the same, requirement of the program we are feeding.
Below is the code I am having I am getting the error: Run-time error 75: Path/File access error.
Error is happening at “Open fileopen for Output as #1” (line 30)
Code:
Private Sub CB_RunQueryPrintReport_Click()
Dim stDocName As String
Dim Filename As String
Dim i As Integer
Dim test As String
Dim MyDB As DAO.Database
Dim REQ As DAO.Recordset
Dim UDI As DAO.Recordset2
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set REQ = MyDB.OpenRecordset("Tbl_REQData", DB_OPEN_TABLE)
Set UDI = MyDB.OpenRecordset("Tbl_UDIData", DB_OPEN_TABLE)
DoCmd.Hourglass True
DoCmd.SetWarnings False
'Set tables before exporting
DoCmd.OpenQuery "Qry_FindPanelParts"
DoCmd.OpenQuery "Qry_PanelsToCut"
DoCmd.OpenQuery "Qry_PanelsToCutAddOn"
DoCmd.OpenQuery "Qry_PanelsToCutAddOn2"
DoCmd.OpenQuery "Qry_PanelsToCutAddOn3"
DoCmd.OpenQuery "Qry_PanelsToCutAddOn4"
'DoCmd.OpenQuery "Qry_ChrParts_Req"
'DoCmd.OpenQuery "Qry_ChrParts_UDI"
Filename = "C:Cherry.csv"
Open Fileopen For Output As #1
REQ.MoveFirst
UDI.MoveFirst
Print #1, REQ("rowt"), ",", REQ("fld2"), ",", REQ("SEQ"), ",", REQ("part"), ",", REQ("fld5"), ",", REQ("Len"), ",", REQ("WID"), ",", REQ("fld8"), ",", REQ("fld9"), ","; REQ("fld10"), ","; REQ("fld11"), ","; REQ("fld12"), ",", REQ("Fld13")
Print #1, UDI.rowt, ",", UDI.fld2, ",", UDI.SEQ, ",", UDI.fld4, ",", UDI.fld5, ",", UDI.Len, ",", UDI.WID, ",", UDI.fld8
Close #1
DoCmd.Hourglass False
DoCmd.SetWarnings True
End Sub
I the file is already created and is blank.
Thanks in advance.
Comment