|
-
Oct 10th, 2015, 12:02 PM
#1
Thread Starter
New Member
[RESOLVED] Database Backup FormatDateTime Issue
Hi Friends
My code works fine when I'm press Cmdbackup
the file generate like this "Saturday, October 10, 2015.mdb"
but i want to change the file name last line adding (hour ,minute,seconds) like that
"Saturday,October10,2015 10 20 58.mdb" <== Here (10 is Hour :20 is Minute and 58 is seconds )
or
Saturday_October_10_2015_10_20_58.mdb
Please help my issue , I hope our forum friends support my code ..
Thanks
Code:
Dim FileSystemObject As Object
Dim strfilename As String
Private Sub cmdBackup_Click()
On Error GoTo e
'set the copying functionality
strfilename = "" + txtPath.Text + "\" + txtFile.Text + ".mdb"
'Set the object contractions
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
'Copy the file according the path settings
FileSystemObject.CopyFile App.Path & "\database\dbp.mdb", strfilename
PrgBar.Visible = True
timPrgBar.Enabled = True
Exit Sub
e:
MsgBox "Invalid Path Setting, Please Try Again", vbCritical, "Invalid Path Setting!"
End Sub
Private Sub cmdclose_Click()
Unload Me
End Sub
Private Sub Dir_Change()
txtPath.Text = "" & Dir.Path
End Sub
Private Sub Drive_Change()
Dim d, fs As Object
'Set the constrctions to created objectes
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(Drive.Drive))
'Set the contents of the selected drives
If d.IsReady Then
Dir.Path = Drive.Drive
Dir.SetFocus
Else
MsgBox "The Drive Is Not Ready!", vbExclamation, "Drive Not Ready!"
End If
End Sub
Private Sub Form_Load()
'Display Today 's date
txtFile.Text = FormatDateTime(Now, vbLongDate)
End Sub
Private Sub timPrgBar_Timer()
Static iCnt As Integer
'Run the timer and check the condition
If iCnt <= 100 Then
PrgBar.Value = iCnt
iCnt = iCnt + 1
Else
MsgBox "The Backup Procedure Has Been Successfully Completed!", vbInformation, "Successful Backup Procedure!"
Drive.SetFocus
PrgBar.Visible = False
timPrgBar.Enabled = False
End If
End Sub
Eagerly waiting for the reply friends,
Thanks for the support advance
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|