Re: Save As command in Access VBA
- From: Tim Ferguson <FergusonTG@xxxxxxxxxxxx>
- Date: Sat, 11 Nov 2006 02:09:07 -0800
=?Utf-8?B?WFA=?= <XP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:8C620F19-9C78-4ECA-939F-C780A86B010B@xxxxxxxxxxxxx:
Using Office 2003 is there a VBA equivalent in Access to Excel's
"SaveCopyAs" command, which saves a copy of the currently open file to
a destination folder, but keeps the current file active?
you could probably do something like this _completely_ untested air code:
' make a new mdb to copy into
set backupdb = CreateDatabase("g:\mybackup.mdb", etc)
backupdb.Close
' handle to currently open db
set cdb = CurrentDB()
' iterate the local tables
for each tdf in cdb.Tabledefs
' ignore the system tables; I doubt the value is
' correct but you can check that in the help files
if tdf.Attributes AND acSystemTable = 0 then
' do the copy command: look up help on the IN clause
jetSQL = "SELECT * " & _
" INTO " & tdf.Name & " IN [g:\mybackup.mdb]"
" FROM " & tdf.Name
' and carry it out
cdb.Execute jetSQL, dbFailOnError
end if
next tdf
but there might be inconsistencies if anyone is using the database at the
time. You won't get the relationships in either, but that's okay because
(a) they might be invalid and (b) they can be reconstructed if you ever
need to recover the backup.
Hope it helps
Tim F
.
- Prev by Date: Re: add item to list box in multiple column
- Next by Date: Re: from Access to SPSS... programmatically
- Previous by thread: Re: Save As command in Access VBA
- Next by thread: Re: Copy Back End while Front End in use
- Index(es):
Relevant Pages
|