Re: Save As command in Access VBA

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



=?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

.



Relevant Pages

  • Re: Q: ALTER TABLE ADD COLUMN does not allow access to this field
    ... when debugging the newly created column (via the ALTER TABLE command) ... circumstances the setting of tdf shows a newly added field (via the ALTER ... TABLE command), and yet it didn't in 2 areas in my Sub. ... prior to Refresh there are X fields in the Fields collection. ...
    (microsoft.public.vb.database.dao)
  • man-db 2.5.1 released
    ... I've released man-db 2.5.1. ... man-db contains an implementation of the man command, ... primary way of examining the on-line help files. ... and adds options to help distribution packaging ...
    (comp.os.linux.announce)
  • Re: computer tower speaker on/off
    ... I did a search in my help files for that, ... I can always hear my computer towers speaker ... > disable Beep device. ... To disable the modem sounds use ATM0 command. ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: Windows Backup Utility in SP2 seems to be broken
    ... The help files show up now and I'll ... see if it makes any difference with ntbackup. ... "A valid backup operation was not specified on the command line." ... > Mark K Vallevand Mark.Vallevand@xxxxxxxxxx ...
    (microsoft.public.windowsxp.embedded)
  • Re: Extracting date file modified from a text file.
    ... good idea to read the help files about any new command you hear about (while ... Rick ... As part of an error checking control step I would like to add some VBA ...
    (microsoft.public.excel.programming)