Kamis, 15 Oktober 2015

RE: [MS_AccessPros] VBScript to open and backup

 

I think VBScript does not need the ()

 

If that fails I would try CStr(Date)

 

Another option is to create a variable to hold the string so you are not relying on the compiler to do the conversion though it should.

 

Dim BackupDate

 

BackupDate = CStr(Date)

 

 

DestinationFile = "S:\FCS\GCS\GCS_Backups\Guiding Children Successfully_" & BackupDate & ".accdb"

 

Bob Peterson

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Thursday, October 15, 2015 11:26 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] VBScript to open and backup

 




Pros,

I'm trying to write a VBScript to backup a DB back end the first time it is opened during a day and open a Front End. The script is failing when I try to insert the date into the Destinationfile. Can someone please help? Here is the script:

dim DestinationFile

dim accessApp
set accessApp = createObject("Access.Application")
DestinationFile = "S:\FCS\GCS\GCS_Backups\Guiding Children Successfully_" & Date() & ".accdb"
Const SourceFile = "s:\FCS\GCS\Guiding Children Successfully.accdb"
Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(DestinationFile) Then
       accessApp.OpenCurrentDataBase("c:\gcsfe\gcsfe.accde")

Else
          ;   fso.CopyFile SourceFile, DestinationFile, True
            accessApp.OpenCurrentDataBase("c:\gcsfe\gcsfe.accde")
    End If
Set fso = Nothing
set accessApp = nothing

 

Doyce




__._,_.___

Posted by: "Robert Peterson" <Bob@AlternateFinishing.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar