Solved

Run-time error 68: Device unavailable

Posted on 1998-11-12
11
1,873 Views
Last Modified: 2012-06-22
I have a problem that's is driving me fool... This is my code:
On Error GoTo TratarError

If pedir_copia then
  frmDirectorio.fraCopia.Visible = True
  frmDirectorio.txtCopia.Text = "A:"
  frmDirectorio.drvCopia.Drive = "A:"
  frmDirectorio.dirCopia.Path = "A:"
End If

TratarError:
  If (Err.Number=68) Then
    MsgBox "Error", 16, "ERROR"
  End If

Now, the problem... If I have a diskette in the A drive, all goes on right. But if I don't have a diskette inserted, I got the "Run-time error 68". I've tried to treat the error in this procedure, and in the event that ".Drive" generates, but I got nothing.
  Someone can help me, please? (sorry for my English)
0
Comment
Question by:amkhara
[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
11 Comments
 
LVL 3

Expert Comment

by:traygreen
ID: 1444482
The error code will always execute because there is nothing to tell it not to.
If the code is in a function put "exit sub" between the "end if" and the "TratarError:"
If in a function put "exit function" between the "end if" and the "TratarError:"

BTW: your English is better than quite a few anglos I know ;)
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1444483
En lo posible, la rutina de tratamiento de errores debe hacer lo minimo indispensable. Si detectas el error 68, puedes bifurcar (via RESUME) a una seccion que trate ese error:

On Error Goto TratarError
bla
bla
bla

End

DeviceUnav:
   MsgBox("bla bla bla")
   Exit Sub

TratarError:
   If Err=68 then Resume DeviceUnav
   On error goto   'Frente a otro error imprevisto, dejar que VB
                   'cancele el programa (o hacer una rutina de
                   'tratamiento de errores imprevistos).

End Sub

Espero que te sirva

0
 

Author Comment

by:amkhara
ID: 1444484
Sorry, sorry, sorry... I forgot Exit Sub, but I have it in my code... Anyway, it doesn't work.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:amkhara
ID: 1444485
Another note: The error code never executes... The program crashes... Maybe, I don't explain it clear enough.
  This is my first question :). Ah! I can't answer during the weekend, so if somebody answers my question then, I'll see the emails on Monday... work!
  Thnx!
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1444486
Tu último comentario dice "The program crashes". ¿Cuál es exactamente el error que muestra cuando el programa se muere? (obviamente debe ser otra cosa, y no el error 68, ya que lo estás interceptando en la sección de errores).

Por favor, contá un poco más el lunes.

0
 

Author Comment

by:amkhara
ID: 1444487
 The program crashes means that... the program crashes giving error 68. So I'm so confused... I've gone on probing my code and I've noticed that program crashes at more points that has "On Error" sentences... Might be a bug?? It seems not to execute error treatment...
  Quiere decir eso... que el programa aborta dando el error 68. Por eso estoy confundida... He seguido probando mi programa y me he dado cuenta de que el programa aborta en mas sitios que tiene sentencias "On Error"... Podria ser un bug?? Parece que no ejecuta el tratamiento de error...
  Have a good weekend! :)
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1444488
You can test your error handling routine whithout need of accessing diskette. Comment out the instruction regarding A: access, and replace it with "Error 68" instruction. That will force error 68 to be generated.

One thing I've noted: your original code does NOT have a RESUME. If (any) error is detected for second time, as RESUME wasn't executed at all, as "pending" flag for that error still remains active, VB takes control and executes its normal procedure, this is, forcing the program to explode.


0
 

Author Comment

by:amkhara
ID: 1444489
You're right, but I've inserted Resume instruction in my code, and goes on crashing... In fact, none of the On Error instructions all over the code goes on right... and all of them have their Resume instruction
Tienes razon, pero he insertado la instruccion Resume y sigue cascando... En realidad, ninguna de las instrucciones On Error del codigo parece que vaya bien... y todas tienen su instruccion Resume
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1444490
¿Could you post, please, the entire error routine you've written?

PS: I'll keep on writting plain English, Amkhara; don't worry if you don't add the Spanish translation.
0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 200 total points
ID: 1444491
I've tested the folowing code and it works well.

--------------------------
On Error GoTo ErrorRoutine
File1.Path = "a:"

Exit Sub

ErrorRoutine:
If Err.Number = 68 Then
    MsgBox Err.Number
    Resume Next
End If
-------------------------

Your code probably is well done but you are using
in the Menu Tools\Options\General section Error Trapping
the Break on All Errors option. With this option checked
even if you have error handling routines in your code the
execution breaks if an error ocurs.

Hope this helps
Regards


0
 

Author Comment

by:amkhara
ID: 1444492
 Thanks all of you for your help... You are right, fguerreiro_inix, I hadn't watched the options... now I've changed them and works fine...
  Gracias vikiing por tu amabilidad...

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

Suggested Solutions

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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