M
mattc66 via AccessMonster.com
I am using the below code to create 5 temp text files. Then it will merge all
5 temp text files into one file.
It is failing at the end, the Shell CmdStr. I am getting an error 53. I am
not sure why. Can anyone help?
Private Sub cmdExp_Click()
Const DEST_NAME As String = "w:\files\Export"
Const DEST_EXT As String = ".txt"
Dim TempFolder As String
Dim FinalName As String
Dim CmdStr As String
Dim Temp1 As String, Temp2 As String, Temp3 As String, Temp4 As String,
Temp5 As String
'Build temp file names using user's temp folder
Temp1 = "c:\Files\Table1.txt"
Temp2 = "c:\Files\Table2.txt"
Temp3 = "c:\Files\Table3.txt"
Temp4 = "c:\Files\Table4.txt"
Temp5 = "c:\Files\Table5.txt"
'Export to temp files
DoCmd.TransferText acExportDelim, , "850_OrderRecord", Temp1, no
DoCmd.TransferText acExportDelim, , "850_DetailRecord", Temp2, no
DoCmd.TransferText acExportDelim, , "850_CommentRecord", Temp3, no
DoCmd.TransferText acExportDelim, , "850_CustomerRecord", Temp4, no
DoCmd.TransferText acExportDelim, , "850_AddressRecord", Temp5, no
'Concatenate using Windows COPY command
FinalName = DEST_NAME & Format(Date, "yyyymmdd") & DEST_EXT
CmdStr = "COPY /B /Y """ _
& Temp1 & """ + """ _
& Temp2 & """ + """ _
& Temp3 & """ + """ _
& Temp4 & """ + """ _
& Temp5 & """ " & FinalName
Shell CmdStr
End Sub
5 temp text files into one file.
It is failing at the end, the Shell CmdStr. I am getting an error 53. I am
not sure why. Can anyone help?
Private Sub cmdExp_Click()
Const DEST_NAME As String = "w:\files\Export"
Const DEST_EXT As String = ".txt"
Dim TempFolder As String
Dim FinalName As String
Dim CmdStr As String
Dim Temp1 As String, Temp2 As String, Temp3 As String, Temp4 As String,
Temp5 As String
'Build temp file names using user's temp folder
Temp1 = "c:\Files\Table1.txt"
Temp2 = "c:\Files\Table2.txt"
Temp3 = "c:\Files\Table3.txt"
Temp4 = "c:\Files\Table4.txt"
Temp5 = "c:\Files\Table5.txt"
'Export to temp files
DoCmd.TransferText acExportDelim, , "850_OrderRecord", Temp1, no
DoCmd.TransferText acExportDelim, , "850_DetailRecord", Temp2, no
DoCmd.TransferText acExportDelim, , "850_CommentRecord", Temp3, no
DoCmd.TransferText acExportDelim, , "850_CustomerRecord", Temp4, no
DoCmd.TransferText acExportDelim, , "850_AddressRecord", Temp5, no
'Concatenate using Windows COPY command
FinalName = DEST_NAME & Format(Date, "yyyymmdd") & DEST_EXT
CmdStr = "COPY /B /Y """ _
& Temp1 & """ + """ _
& Temp2 & """ + """ _
& Temp3 & """ + """ _
& Temp4 & """ + """ _
& Temp5 & """ " & FinalName
Shell CmdStr
End Sub