100+
P: 121
|
I have a somewhat simple question, but have been baffled by it for a while, and now I'm on a tight deadline - have to get it done within 24 hours.
I am trying to export a set of files to my hard drive to then later be FTPd to a server. the file format should be "TITLE.yyyymmdd" where yymmdd is the date code for when the files are created.
The files can't be .txt. But when I run the files as ".txt" the code runs just fine. when I change them to run to ".yyyymmdd" I get an error saying "Database or object is read only" and the debug points me to the line i have marked with a Bold Asterisk below.
Thanks for any help that can be shed
Here's the code I want to run, but can't: -
Function Export_Ouput_Files()
-
Dim NewFldr As String
-
Dim DT_Fldr As String
-
Dim DT_Code_ST As String
-
Dim DT_Code As String
-
Dim DT_YR As String
-
Dim DT_TM As String
-
Dim fs As Object
-
-
DT_Code_ST = Now()
-
DT_YR = Format(DT_Code_ST, "yyyymmdd")
-
DT_TM = Format(DT_Code_ST, "hhmmss")
-
-
DT_Code = DT_YR & "-" & DT_TM
-
DT_Fldr = "C:\DLU\Outgoing\" & DT_YR & "\"
-
NewFldr = DT_Fldr & DT_TM & "\"
-
-
Set fs = CreateObject("Scripting.FileSystemObject")
-
-
If Not fs.FolderExists(DT_Fldr) Then
-
fs.CreateFolder DT_Fldr
-
MkDir NewFldr
-
-
DoCmd.TransferText acExportDelim, "BP_ATNDE_FILE Export Specification", "BP_ATNDE_FILE", NewFldr & "BP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CD_DS_FILE Export Specification", "CD_DS_FILE", NewFldr & "CD_DS-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CUST_INPT_Vality Export Specification", "CUST_INPT_Vality", NewFldr & "CUST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EVNT_FILE Export Specification", "EVNT_FILE", NewFldr & "EVNT-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EXP_FILE Export Specification", "EXP_FILE", NewFldr & "EXP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "INSN_ORGZN_Vality Export Specification", "INSN_ORGZN_Vality", NewFldr & "INST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "PRD_FILE Export Specification", "PRD_FILE", NewFldr & "PRD-TEST." & DT_YR, False, ""
-
-
Beep
-
MsgBox "All Files have Been Exported to: " & NewFolder, vbInformation, "Export Complete"
-
-
-
Else
-
-
MkDir NewFldr
-
-
* DoCmd.TransferText acExportDelim, "BP_ATNDE_FILE Export Specification", "BP_ATNDE_FILE", NewFldr & "BP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CD_DS_FILE Export Specification", "CD_DS_FILE", NewFldr & "CD_DS-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CUST_INPT_Vality Export Specification", "CUST_INPT_Vality", NewFldr & "CUST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EVNT_FILE Export Specification", "EVNT_FILE", NewFldr & "EVNT-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EXP_FILE Export Specification", "EXP_FILE", NewFldr & "EXP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "INSN_ORGZN_Vality Export Specification", "INSN_ORGZN_Vality", NewFldr & "INST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "PRD_FILE Export Specification", "PRD_FILE", NewFldr & "PRD-TEST." & DT_YR, False, ""
-
-
Beep
-
MsgBox "All Files have Been Exported to: " & NewFldr, vbInformation, "Export Complete"
-
-
End If
-
-
End Function
-
| |
Share this Question
Expert 100+
P: 280
|
Why dont u then just export it as a .txt file (TransferText accepts certain suffixes only)
then after export, rename it
eg
FileCopy "oldfile","newfile"
Kill "oldfile"
| | Expert 5K+
P: 8,668
|
I have a somewhat simple question, but have been baffled by it for a while, and now I'm on a tight deadline - have to get it done within 24 hours.
I am trying to export a set of files to my hard drive to then later be FTPd to a server. the file format should be "TITLE.yyyymmdd" where yymmdd is the date code for when the files are created.
The files can't be .txt. But when I run the files as ".txt" the code runs just fine. when I change them to run to ".yyyymmdd" I get an error saying "Database or object is read only" and the debug points me to the line i have marked with a Bold Asterisk below.
Thanks for any help that can be shed
Here's the code I want to run, but can't: -
Function Export_Ouput_Files()
-
Dim NewFldr As String
-
Dim DT_Fldr As String
-
Dim DT_Code_ST As String
-
Dim DT_Code As String
-
Dim DT_YR As String
-
Dim DT_TM As String
-
Dim fs As Object
-
-
DT_Code_ST = Now()
-
DT_YR = Format(DT_Code_ST, "yyyymmdd")
-
DT_TM = Format(DT_Code_ST, "hhmmss")
-
-
DT_Code = DT_YR & "-" & DT_TM
-
DT_Fldr = "C:\DLU\Outgoing\" & DT_YR & "\"
-
NewFldr = DT_Fldr & DT_TM & "\"
-
-
Set fs = CreateObject("Scripting.FileSystemObject")
-
-
If Not fs.FolderExists(DT_Fldr) Then
-
fs.CreateFolder DT_Fldr
-
MkDir NewFldr
-
-
DoCmd.TransferText acExportDelim, "BP_ATNDE_FILE Export Specification", "BP_ATNDE_FILE", NewFldr & "BP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CD_DS_FILE Export Specification", "CD_DS_FILE", NewFldr & "CD_DS-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CUST_INPT_Vality Export Specification", "CUST_INPT_Vality", NewFldr & "CUST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EVNT_FILE Export Specification", "EVNT_FILE", NewFldr & "EVNT-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EXP_FILE Export Specification", "EXP_FILE", NewFldr & "EXP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "INSN_ORGZN_Vality Export Specification", "INSN_ORGZN_Vality", NewFldr & "INST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "PRD_FILE Export Specification", "PRD_FILE", NewFldr & "PRD-TEST." & DT_YR, False, ""
-
-
Beep
-
MsgBox "All Files have Been Exported to: " & NewFolder, vbInformation, "Export Complete"
-
-
-
Else
-
-
MkDir NewFldr
-
-
* DoCmd.TransferText acExportDelim, "BP_ATNDE_FILE Export Specification", "BP_ATNDE_FILE", NewFldr & "BP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CD_DS_FILE Export Specification", "CD_DS_FILE", NewFldr & "CD_DS-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "CUST_INPT_Vality Export Specification", "CUST_INPT_Vality", NewFldr & "CUST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EVNT_FILE Export Specification", "EVNT_FILE", NewFldr & "EVNT-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "EXP_FILE Export Specification", "EXP_FILE", NewFldr & "EXP-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "INSN_ORGZN_Vality Export Specification", "INSN_ORGZN_Vality", NewFldr & "INST-TEST." & DT_YR, False, ""
-
DoCmd.TransferText acExportDelim, "PRD_FILE Export Specification", "PRD_FILE", NewFldr & "PRD-TEST." & DT_YR, False, ""
-
-
Beep
-
MsgBox "All Files have Been Exported to: " & NewFldr, vbInformation, "Export Complete"
-
-
End If
-
-
End Function
-
The problem is that ' yyyymmdd' is not a recognizable File Extension to be utilized with the TransferText() Method. Implement ' yyyymmdd' within the File's Base Name and use the .txt Extension.
| | Expert 100+
P: 280
|
eg -
Function Export_Ouput_Files()
-
-
Dim NewFldr As String
-
Dim DT_Fldr As String
-
Dim DT_Code_ST As String
-
Dim DT_Code As String
-
Dim DT_YR As String
-
Dim DT_TM As String
-
Dim fs As Object
-
-
DT_Code_ST = Now()
-
DT_YR = Format(DT_Code_ST, "yyyymmdd")
-
DT_TM = Format(DT_Code_ST, "hhmmss")
-
-
DT_Code = DT_YR & "-" & DT_TM
-
DT_Fldr = "C:\DLU\Outgoing\" & DT_YR & "\"
-
NewFldr = DT_Fldr & DT_TM & "\"
-
-
Set fs = CreateObject("Scripting.FileSystemObject")
-
-
If Not fs.FolderExists(DT_Fldr) Then
-
fs.CreateFolder DT_Fldr
-
MkDir NewFldr
-
End If
-
-
-
DoCmd.TransferText acExportDelim, "BP_ATNDE_FILE Export Specification", "BP_ATNDE_FILE", NewFldr & "BP-TEST.txt", False, ""
-
RenameSuffix NewFldr & "BP-TEST.txt", DT_YR
-
-
DoCmd.TransferText acExportDelim, "CD_DS_FILE Export Specification", "CD_DS_FILE", NewFldr & "CD_DS-TEST.txt", False, ""
-
RenameSuffix NewFldr & "CD_DS-TEST.txt", DT_YR
-
-
DoCmd.TransferText acExportDelim, "CUST_INPT_Vality Export Specification", "CUST_INPT_Vality", NewFldr & "CUST-TEST.txt", False, ""
-
RenameSuffix NewFldr & "CUST-TEST.txt", DT_YR
-
-
DoCmd.TransferText acExportDelim, "EVNT_FILE Export Specification", "EVNT_FILE", NewFldr & "EVNT-TEST.txt", False, ""
-
RenameSuffix NewFldr & "EVNT-TEST.txt", DT_YR
-
-
DoCmd.TransferText acExportDelim, "EXP_FILE Export Specification", "EXP_FILE", NewFldr & "EXP-TEST.txt", False, ""
-
RenameSuffix NewFldr & "EXP-TEST.txt", DT_YR
-
-
DoCmd.TransferText acExportDelim, "INSN_ORGZN_Vality Export Specification", "INSN_ORGZN_Vality", NewFldr & "INST-TEST.txt", False, ""
-
RenameSuffix NewFldr & "INST-TEST.txt", DT_YR
-
INST -Test
-
DoCmd.TransferText acExportDelim, "PRD_FILE Export Specification", "PRD_FILE", NewFldr & "PRD-TEST.txt", False, ""
-
RenameSuffix NewFldr & "PRD-TEST.txt", DT_YR
-
-
Beep
-
MsgBox "All Files have Been Exported to: " & NewFolder, vbInformation, "Export Complete"
-
-
-
End Function
-
-
Public Sub RenameSuffix(ByVal sFile As String, ByVal sNewSuffix As String)
-
-
Dim sNewFile As String
-
-
sNewFile = Replace(sFile, ".txt", sNewSuffix)
-
-
FileCopy sFile, sNewFile
-
Kill sFile
-
-
End Sub
-
| | Expert 100+
P: 280
|
note rogue entry in between code I posted
this is just on its own, just remove it
INST -Test
| | 100+
P: 121
|
Why dont u then just export it as a .txt file (TransferText accepts certain suffixes only)
then after export, rename it
eg
FileCopy "oldfile","newfile"
Kill "oldfile"
You know what - I feel like an idiot. I knew there would be a really easy solution. I just got so engrossed in trying to figure out why I was getting the error that I was ignoring other options. Oh well, that is why this forum is so great.
It works fine now - Thanks again!
| | | | Question stats - viewed: 2863
- replies: 5
- date asked: Apr 11 '07
|