Error Handling.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a small problem. The folowing code works perfectly exect in one erea.
When BASS_FTP generates an error the function jumps to "BASSREFTP_ERROR"?
as you can see, the message "That file is missing!" will be displayed. I
don't wont that message to display if the function "BASS_FTP" runs.

BASS_FTP has it own error messages.

I thought defining a 2nd error module would do it. I did not.

Ideals?

Scott Burke



Private Sub CMD_BASREFTP_Click()
On Error GoTo BASSREFTP_ERROR
Dim Fn1 As String
Dim FN1B As String
Dim Fs
Dim Fn

Rem Create the names
Fn1 = "T:\CLEARWIN\FTP\BMS\" & "PCC" & Format(Me.Date1, "YYYYMMDD") &
".TXT"
FN1B = "PCC" & Format(Me.Date1, "YYYYMMDD") & ".TXT"

Rem check for the files. dont do if
Rem file don't exist.
Set Fs = CreateObject("Scripting.fileSystemObject")
Set Fn = Fs.GetFile(Fn1)


Rem Great the file are there. Lets FTP it!
On Error GoTo BASSREFTP_ERROR2:
Call BASS_FTP(FN1B, Fn1)

BASSREFTP_ERROR:
MsgBox "That file is missing!", vbOKOnly, "RE-FTP Report"
DoCmd.Hourglass False
Exit Sub

BASSREFTP_ERROR2:
Exit Sub
End Sub
 
Scott,

Are you sure that BASS_FTP is generating an error in the first place? Try
inserting
an "Exit Sub" command after the sub call:
.....
Call BASS_FTP(FN1B, Fn1)

Exit Sub
BASSREFTP_ERROR:
.....

It looks like your program is executing fine, but there is no command to stop
execution
before the first error statement. The program just goes ahead and runs the
error routine
because it doesn't know to stop.

HTH,
Nick
 
I think all you need is an "Exit Sub" line immediately after the "Call
BASS_FTP" line. You shouldn't need the second error callout.

The problem is that after the BASS_FTP call, your code does not know it is
done, so it goes to the next line, which is the message box for the error.
 
You are right. The program did not know when to stop.

I was under the impression that everything in "BASSREFTP_ERROR" was isolated.
I learn somthing new today.

Thank You
Scott Burke
 
Back
Top