Qns On Copying 2 Files From A Folder To Another Folder.

S

Seikyo

How can I copy 2 files from one (I need to specified the location of the
files) to another folder. I try to use the Function as shown
http://www.mvps.org/access/api/api0001.htm but found out that the files that
I find does not save in another folder. Is there any error with my syntax?

Private Sub UpdateFiles_Click()
On Error GoTo Err_UpdateFiles_Click

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "dBase Files(*.dbf)", "*.dbf")


Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim SourceFile, DestinationFile

'Clear Listbox Contents.
'lstFilelist.RowSource = ""

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = True
.Title = "Please Select The Location Of Tim1 And Tim2 You Want To
Import"
.Filters.Clear
.Filters.Add "DBase Files", "*.dbf"
'Show the dialog box. If the .Show method returns True, the
'User Picked At Least One File. If The .Show Method Returns
'False, The User Clicked Cancel.
If .Show = True Then
' Loop through each file selected and add it to our list box.
' I've added to a list box...You Could Put the code I Provided
previously with
' A slight hack and copy the files you need using filecopy.
For Each varFile In .SelectedItems
'Me.lstFilelist.AddItem varFile
varFile = ahtCommonFileOpenSave(InitialDir:="C:\",
OpenFile:=False, Filter:=strFilter, Flags:=ahtOFN_OVERWRITEPROMPT Or
ahtOFN_READONLY)
DoCmd.RunMacro "Update TimeCard"
MsgBox "Update Completed", vbOKCancel, "Message Box"
Next
Else
MsgBox "The Action Is Cancelled."
End If
End With

ExitErr_UpdateFiles_Click:
DoCmd.SetWarnings True
DoCmd.Hourglass False
Exit Sub

Err_UpdateFiles_Click:
MsgBox Err.Description
Resume ExitErr_UpdateFiles_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top