Code question

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thanks for reading this post. It's really appreciated.

I have a form that has a "backup" command button.
The complete code is below. It is at line 60 where my question is. What I
want to do is to backup another database. It is separate from the one this
form/database uses.

I was wondering if I could use:
strcopyfile = f:\db2 & "\Copy of " & f:\db2

Private Sub cmdtoggle_Click()
Dim strSQL
Dim strcopyfile, strSQL1 As String
On Error GoTo cmdtoggle_Click_Error

10 strSQL1 = "Update tblbackup set tblbackup.fcopy = False"
20 CurrentDb.Execute strSQL1, dbFailOnError

' *** Save the backup date ***
40 strSQL = "UPDATE tblbackup SET tblbackup.bkdate = now()"
50 CurrentDb.Execute strSQL, dbFailOnError

-----> '*** Defines the Backup Name ***
-----> 60 strcopyfile = CurrentProject.Path & "\Copy of " &
CurrentProject.Name

'*** Checks to see if there is a back up. If so then
deletes it ***
70 If Len(Dir(strcopyfile)) > 0 Then
80 Kill strcopyfile
90 End If

'*** Makes a backup copy & closes the frmBKBox ***
100 fMakeBackup
110 Me.Parent.ENTERBUTTON.SetFocus
120 Forms("frmPersonnel_Menu")!frmbkbox.Visible = False

130 Exit Sub


On Error GoTo 0
Exit Sub

cmdtoggle_Click_Error:
Err.Description = Err.Description & " In Procedure " & "cmdtoggle_Click
of VBA Document Form_frmBkBox"
Call LogError(Err.Number, Err.Description, "cmdtoggle_Click")

End Sub
 
T

Tom van Stiphout

On Mon, 02 Nov 2009 15:48:59 GMT, "Afrosheen via AccessMonster.com"

If I understand you correctly, that's a curious question. Let's say
that it worked, and strCopyFile would then be (ignoring syntax errors
for a moment):
f:\db2\Copy of f:\db2
Clearly that's not a legal file name. Just try renaming any test file
to this name.

OTOH, line 60 looks OK to me. What's wrong with it?

-Tom.
Microsoft Access MVP
 
A

Afrosheen via AccessMonster.com

Thanks Tom for your reply.
I'll change the database name to something other than db2.
For calcification, the program works as is. It makes a copy of it self called
Copy of xyz while it is in the program.

What I want it to do is say the database name is called TurboTable. It is
located on C:\ drive. I have another table called Loader. The loader database
has a button on it called Save. Since it is not recommended to do backups
while in the table, I want the loader program/button to make a backup outside
of the file TurboTable.

I thought line 60 was the key.

The people I'm dealing with are kinda computer challenged when it comes to
backups. I would like to eventually be able to put it on a flash drive so
when the "real" computer person has to reinstall the computer he won't loose
the program.

If I understand you correctly, that's a curious question. Let's say
that it worked, and strCopyFile would then be (ignoring syntax errors
for a moment):
f:\db2\Copy of f:\db2
Clearly that's not a legal file name. Just try renaming any test file
to this name.

OTOH, line 60 looks OK to me. What's wrong with it?

-Tom.
Microsoft Access MVP
Thanks for reading this post. It's really appreciated.
[quoted text clipped - 44 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top