Thanks rob
I did this not very sure its correct logic but look tricky .....
This code for beginner programmer like me
Both Solution is easy but its good to have look on both of them its good for future task
' Stores Directory path and File Name
Dim DirectoryFileName As String
' Dialog box for Destination folder
Private Sub cmdDirectoryPath_Click()
On Error GoTo Errorhandler
Me.txtDirectoryPath = SelectDir("", , , "Select destination for backup")
If Not IsNull(Me.txtFileName) Then
' Separating File name with GetNamePart Method and then concatenate it with Destination folder and we rename it here to save our self from from complexity
DirectoryFileName = Me.txtDirectoryPath & "\" & GetNamePart(Me.txtFileName)
End If
Exit Sub
Errorhandler:
MsgBox "Error: " & Err.Description & " (" & Err.number & ")"
End Sub
------------------------------
' select file you want to back up
Private Sub cmdSelectFile_Click()
On Error GoTo Errorhandler
Me.txtFileName = OpenFile(Me.txtFileName)
Exit Sub
Errorhandler:
MsgBox "Error: " & Err.Description & " (" & Err.number & ")"
End Sub
-------------------------------
' extract filename and give it new name
Function GetNamePart(strIn As String) As String
Dim i As Integer
Dim strTmp As String
For i = Len(strIn) To 1 Step -1
If MID$(strIn, i, 1) <> "\" Then
'strTmp = MID$(strIn, i, 1) & strTmp
strTmp = MID$(strIn, i, 1) & strTmp
Else
Exit For
End If
Next i
GetNamePart = Format(Int(Now()), "ddmmyy") & "_Backup_" & strTmp
End Function
call this method to actually copy files over
FileCopy Me.txtFileName, DirectoryFileName
' this any thing with files check msdn
http://msdn.microsoft.com/archive/de...ce09072000.asp
Regards
Ayaz