473,378 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Check for Backup file before deleting

I have a database that does an auto backup of some data before
closing. I also have it set up to delete all backup files older than
5 days. I can't figure out how to check if the file is there and to
keep from getting the "File not found" error.

Any help is greatly appreciated,

Thank you,
ShyGuy
Nov 13 '05 #1
5 1534
Search in the newsgroup archives for a thread 'Detecting If Table
Exists'. There's a handy function in there by David Fenton called
'DoesObjectExist' that I use quite often.

Let us know if you need any help with it (or can't find it)!

-------
LoopyNZ
-------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
I apologise, I should read the question properly before replying.
*SLAPS HERSELF*

New answer: Look in the help at the 'Dir' function.

Excerpt: Dir returns the first file name that matches pathname. To get
any additional file names that match pathname, call Dir again with no
arguments. When no more file names match, Dir returns a zero-length
string ("").

-------
LoopyNZ
-------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
Thanks for the quick reply, I tried the Dir function, but I'm afraid
I'm lost. I tried to use it in an if statement and it doesn't seem
to work. The Backup files are saved in the following format

DB Backup 8-27-2004.mdb

I use the following to create each days backup name.

"C:\DB Backup " & Month(Now()) & "-" & Day(Now()) & "-" & Year(Now())
& ".mdb"

I tried setting Myfile to the above, then
If myfile = True then Kill "the file"
but it doesn't work.

I know I'm doing something wrong but don't know enough to figure it
out.

Thanks for your help.

On 27 Aug 2004 14:52:54 GMT, LoopyNZ <Lo*****@NOguruSPPAM.net.nz>
wrote:
I apologise, I should read the question properly before replying.
*SLAPS HERSELF*

New answer: Look in the help at the 'Dir' function.

Excerpt: Dir returns the first file name that matches pathname. To get
any additional file names that match pathname, call Dir again with no
arguments. When no more file names match, Dir returns a zero-length
string ("").

-------
LoopyNZ
-------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 13 '05 #4
ShyGuy <sh****@shytown.com> wrote in message news:<ql********************************@4ax.com>. ..
Thanks for the quick reply, I tried the Dir function, but I'm afraid
I'm lost. I tried to use it in an if statement and it doesn't seem
to work. The Backup files are saved in the following format

DB Backup 8-27-2004.mdb

I use the following to create each days backup name.


I tried setting Myfile to the above, then
If myfile = True then Kill "the file"
but it doesn't work.

I know I'm doing something wrong but don't know enough to figure it
out.


Shy,

try something like this:

Public Function FileExists(ByVal strFilePath As String) As Boolean
If Len(Dir(strFilePath, vbNormal)) Or Len(Dir(strFilePath, vbArchive)) Then
FileExists = True
Else
FileExists = False
End If
End Function

then your routine would be something like:
'watch the WRAP!
dim strFileName as string
strFileName =
"C:\DB Backup " & Month(Now()) & "-" & Day(Now()) & "-" & Year(Now()) & ".mdb"

if FileExists(strFileName) then
kill strFileName
end if
'--put your code to save your backup copy here somewhere...
Nov 13 '05 #5
Thank you so much. It worked great!!

Shyguy
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raquel | last post by:
I am a newbie to UDB and reading the backup processes on UDB which look pretty good to me. Now, if these good backup and recovery procedures are already available 'within' UDB, what extra...
2
by: V_S_H_Satish | last post by:
Dear Friends I am working as oracle and ms sql dba from last 4 years. My company recently migrated to DB2 databases. So i am very much new to db2 database Can any one pls provide script to...
6
by: k04jg02 | last post by:
Problem: I have a properties dialog. X objects build the dialog, but a subclass of X, such as Y, can add more options to the dialog for Y specific properties. I would like to write code for the...
3
by: jjsaper0729 | last post by:
I have created two backup devices for a database: 1 for the data and 1 for the logs. I back up transaction logs to the device over the course of a day and then do a differential backup for the data...
2
by: rdemyan via AccessMonster.com | last post by:
For some of my really important tables, I have backup tables in the backend file. The idea is that if a user accidentally screws up data, they can go to a form and restore from the backup table...
4
by: Mark | last post by:
Good morning. I recently made some changes to my Access project, and I introduced some problems that I could not resolve. So I deleted the forms that I had altered and saved the project. Then I...
1
by: Bryan | last post by:
We have a SQL 2005 server running the following backup job: EXECUTE master.dbo.xp_create_subdir N'\\Server\Backups\DBServerName\\DB_Name__METABASE' GO EXECUTE master.dbo.xp_create_subdir...
6
by: sara440 | last post by:
i want to take backup of one table(tables's data) of database, on hard disk or cd.i have a button "backup" on my form that should ask for backup when clicked.(it should allow to take backup on Cd). ...
0
by: yellr | last post by:
Hi guys, im facing a strange problem with the db2 backup size, our last backups have had the following sizes: 18G 24G 26G 20G
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.