G
Guest
Hello,
I am trying to copy an OS File name using a combination of a Record in a
Table in my database plus the original file name to create a backup file. For
example the Record in the table is the Store Number which is string "049".
The original file name is PL110404.PRN. I want the new file name to be
049PL110404.PRN.
The table which stores my information will always only have one value in it.
Here is my code that I have now. All help will be appreciated!
Public Function ImportFileHandling()
On Error GoTo Err_ImportFileHandling
Dim rs As New ADODB.Recordset
Dim Store As String
Dim bFName As String
Dim sFName As String
Dim pFName As String
rs.CursorLocation = adUseClient
rs.Open "Select Store from tStoreNumber", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic
rs.MoveFirst
Store = rs.Fields("Store")
Const cFName = "PL*.PRN"
sFName = Dir(gsPath & cFName)
bFName = Dir(gsPath & "Store" & cFName)
pFName = Dir(gsPath & bFName)
FileCopy gsPath & sFName, gsPath & "PLTW.csv"
FileCopy gsPath & sFName, gsPath & "Bak\" & bFName
Kill gsPath & sFName
Set rs = Nothing
Exit_ImportFileHandling:
Exit Function
Err_ImportFileHandling:
MsgBox Err.Description
Resume Exit_ImportFileHandling
End Function
I am trying to copy an OS File name using a combination of a Record in a
Table in my database plus the original file name to create a backup file. For
example the Record in the table is the Store Number which is string "049".
The original file name is PL110404.PRN. I want the new file name to be
049PL110404.PRN.
The table which stores my information will always only have one value in it.
Here is my code that I have now. All help will be appreciated!
Public Function ImportFileHandling()
On Error GoTo Err_ImportFileHandling
Dim rs As New ADODB.Recordset
Dim Store As String
Dim bFName As String
Dim sFName As String
Dim pFName As String
rs.CursorLocation = adUseClient
rs.Open "Select Store from tStoreNumber", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic
rs.MoveFirst
Store = rs.Fields("Store")
Const cFName = "PL*.PRN"
sFName = Dir(gsPath & cFName)
bFName = Dir(gsPath & "Store" & cFName)
pFName = Dir(gsPath & bFName)
FileCopy gsPath & sFName, gsPath & "PLTW.csv"
FileCopy gsPath & sFName, gsPath & "Bak\" & bFName
Kill gsPath & sFName
Set rs = Nothing
Exit_ImportFileHandling:
Exit Function
Err_ImportFileHandling:
MsgBox Err.Description
Resume Exit_ImportFileHandling
End Function