VBA Vs Batch file for backup...I need some help??

What I am trying to do is

FileCopy "C:\ViperResides\Viper.mdb", "\\MikeHP\ViperDaily\" & Format([Forms]![CodeBUSystem]![Current]) + ".mdb"

Forms!CodeBUSystem!abc = 1

and when other computer is connected

Forms!CodeBUSystem!abc = 2

I had some success with

On Error Goto ErrHandler:
N = 1 / 0 ' cause an error
'
' more code
'
Exit Function (and leaving it out)
ErrHandler:

Forms!CodeBUSystem!abc = 1

Resume Next

But On Error Resume Next seems to be cancelled for the next lines which are copying across the network.

More work to be done:D


 
Well I got around that and it is now working with the full thing and with computer on or off

In a module I put

FileCopy "C:\ViperResides\Viper.mdb", "\\MikeHP\ViperDaily\" & Format([Forms]![CodeBUSystem]![Current]) + ".mdb"

Forms!CodeBUSystem!abc = 1

The called it in the module that runs it all and done this way

On Error Resume Next

Call CompOff

So [abc] remans at 0 when the computer is turned off and thus

If Forms!CodeBUSystem!abc = 1 Then
DoCmd.OpenForm "BUExp", acNormal, "", "", , acNormal
DoCmd.GoToRecord , "", acNewRec
Forms!BUExp!DiskBU = "Copied to Computer 1 "

End If

If Forms!CodeBUSystem!abc = 0 Then
DoCmd.OpenForm "BUExp", acNormal, "", "", , acNormal
DoCmd.GoToRecord , "", acNewRec
Forms!BUExp!DiskBU = "Computer 1 was turned off or network not working"
End If

A work around to be sure but I need to have the "on screen progress" by later today and it now 4.10am. Cutting it fine:D
 

Users who are viewing this thread

Back
Top Bottom