How to set a reference to the 'Microsoft Scripting Runtime' (1 Viewer)

Di7bash

New member
Local time
Today, 08:10
Joined
Mar 2, 2006
Messages
8
Hello everyone,

I am using the following code (which i got by using the search function in the website":

Code:
Public Function BackupCopy() 

'This function will allow you to copy a db that is open, 

'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work! 

Dim fso As FileSystemObject 

Dim sSourcePath As String 
Dim sSourceFile As String 
Dim sBackupPath As String 
Dim sBackupFile As String 

sSourcePath = "C:\Database\" 
sSourceFile = "MyDB.mdb" 
sBackupPath = "C:\Database\Backups\" 
sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb" 

Set fso = New FileSystemObject 
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True 
Set fso = Nothing 

Beep 
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed" 

End Function

My question is where and how to set a reference to the 'Microsoft Scripting runtime'?
Iam a beginner so please bear with me..

Di7bash
 

mdjks

Registered User.
Local time
Today, 09:10
Joined
Jan 13, 2005
Messages
96
go into a module and click on tools, references and scroll down to Microsoft scripting runtime. click the check box and then ok.
 

Di7bash

New member
Local time
Today, 08:10
Joined
Mar 2, 2006
Messages
8
Works like a charm.
Thanks to everyone who contributed to this code and thanks mjdks

Di7bash
 

Di7bash

New member
Local time
Today, 08:10
Joined
Mar 2, 2006
Messages
8
Does anyone know how can i modify this code in order for it to backup once a week or even a month instead of backing up everytime you click a button.

Thanks in advance
 

ghudson

Registered User.
Local time
Today, 10:10
Joined
Jun 8, 2002
Messages
6,195
Use a timer if the db is always open or the Windows scheduler to open the db.
 

Di7bash

New member
Local time
Today, 08:10
Joined
Mar 2, 2006
Messages
8
I am sorry ghudson this is my first time to make access applications and i've been asking al these stupid questions.

Currently i placed the code to be called by a button click so where should i put the code if i wanna use the windows scheduler. The scheduler asks me what application do i want windows to run, should i choose my databse or something else?
I am lost...Heeeeeeeeeeeeeeeelp :D

Thanks alot for your timely replies ghudson.

Di7bash
 

Users who are viewing this thread

Top Bottom