Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quit the procedure if cannot find the server folder 1

Status
Not open for further replies.

PDAnalyst

Technical User
Dec 2, 2005
72
0
0
US
Hi,

I have an application that copies specific files from the local drive to a server, then gives the user a message box that states how many files have been moved, then makes a backup copy to an archieve folder on the local drive and finally replaces the original files with blank ones.

I have created an error trap just in case if the user is not connected to the server. The problem is that in my code even after the "GoTo NoDriveMapped" is executed, the code returns back to the procedure and then executes the message box that states how many files have been copied, then backs up the files to a local folder and erases the original files.

What I need is that after the NoDriveMapped error trap, I want the whole thing to end.

Any pointers is appreciated,

Safa

****CODE******

Private Sub CmdStartTrnsfr_Click()
FileOperation fovCopy, "C:\CGRAS\SM_Geography\Graffiti.*", "\\Csmfs\\GRAFFITI_1", fofNoConfirmMakeDir
'CHANGE THE FOLDER LOCATIONS AND SERVER NAMES HERE

Dim sSource As String
Dim sFileType As String
Dim numFiles As Long

'initialize values
sSource = "\\Csmfs\GRAFFITI_1\"
'CHANGE THIS DIRECTORY NAME FOR EACH INDIVIDUAL MACHINE FOLDER
sFileType = "Graffiti.*"

'get the count
numFiles = FilesCountAll(sSource, sFileType)
If numFiles = 0 Then

GoTo NoDriveMapped

Else
MsgBox "Copying Completed Successfully!" & vbNewLine & vbNewLine & numFiles & " files copied to: " & sSource _
, vbOKOnly Or vbInformation _
, "CGRAS GRAFFITI SYSTEM"

Call BackupFilestoLocal

End
End If
Exit Sub

NoDriveMapped:
MsgBox "Copying Failed !!! - MAKE SURE YOU ARE CONNECTED TO THE WIRELESS ACCESS", vbCritical, "NO MAPPED DRIVE"
Exit Sub

 
Try putting an

Exit Sub

directly after the the line

GoTo NoDriveMapped

 
Hi Safa,

Just a thought, seems it doesn't actually throw an error, you haven't really got a need to error handle it per se (or at least avoid an unnecesary Goto statement that isn't "On Err Goto"). A simpler (and easier to work with) construct might be:
Code:
'get the count
   numFiles = FilesCountAll(sSource, sFileType)
   If numFiles > 0 Then
      MsgBox "Copying Completed Successfully!" & vbNewLine & vbNewLine & numFiles & " files copied to:  " & sSource _
          , vbOKOnly Or vbInformation _
          , "CGRAS GRAFFITI SYSTEM"
          
      Call BackupFilestoLocal

   Else
      MsgBox "Copying Failed !!! - MAKE SURE YOU ARE CONNECTED TO THE WIRELESS ACCESS", vbCritical, "NO MAPPED DRIVE"
   End If
Exit Sub
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top