Solved

error runtime messages when open file

Posted on 2000-05-02
4
144 Views
Last Modified: 2010-05-02
When I try to open a file which is not currently closed by another program (ex : a log of a backup exec program), I have a runtime error.

I would like to capture the error message with my open command.

Ex :
 Open ch_origine + nom For Input As #1
 
'Here I want to know if an error has been met, not to do the rest of code.
       
 Do Until EOF(1) Or dejafait
...

Thank you for your answer, and sorry for my trivial questions.

Apydya    
0
Comment
Question by:apydya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 2769663
Private Sub Command1_Click()
On Error GoTo trap
Open ch_origine + nom For Input As #1
On Error GoTo 0   'turn off error trap

Rem your code

Close #1

Exit Sub

trap:

    MsgBox "Error on open"

End Sub

OR DO THIS

Private Sub Command1_Click()
On Error Resume Next
Error.Clear
Open ch_origine + nom For Input As #1
If Error.num <> 0 Then

    MsgBox "Error on open"

Else

    On Error GoTo 0   'turn off error trap

    Rem your code

    Close #1

End If

End Sub
0
 
LVL 18

Expert Comment

by:deighton
ID: 2769693
deighton changed the proposed answer to a comment
0
 
LVL 18

Accepted Solution

by:
deighton earned 40 total points
ID: 2769698
Private Sub Command1_Click()
On Error Resume Next
Err.Clear
Open ch_origine + nom For Input As #1

If Err.Number <> 0 Then

    MsgBox "Error on open " & Err.Description

Else

    On Error GoTo 0   'turn off error trap

    Rem your code

    Close #1

End If

End Sub
0
 

Author Comment

by:apydya
ID: 2791399
You answer + comment is perfect.
Thank you for the time you spent.
Have a nice day.
Patrick
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question