Link to home
Start Free TrialLog in
Avatar of dspavlik
dspavlik

asked on

Path not found handeling

I have a small little program that loads archived htm files.  I need to know how to handel a path not found error if users don't choose the proper directory.  Here is the code I have.  I am week with error handeling.  thanks

Private Sub Command1_Click()
    Dim month As String
    Dim year As String
    Dim root As String
    root = "G:\Shared\saved_rates"
    month = Combo1.Text
    year = Combo2.Text
    File1.Path = root & "\" & year & "\" & month & "\"
    If Err.Number 76 Then
        MsgBox "Please choose a time period when rates were posted" = vbOK
        Resume
    End If
   
End Sub
ASKER CERTIFIED SOLUTION
Avatar of PatOBrien
PatOBrien

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:

Private Sub Command1_Click()
   Dim month As String
   Dim year As String
   Dim root As String
   On Error GoTo ERRHANDLER
   root = "G:\Shared\saved_rates"
   month = Combo1.Text
   year = Combo2.Text
   File1.Path = root & "\" & year & "\" & month & "\"
   Exit Sub
ERRHANDLER:
    MsgBox Err.Number & " " & Err.Description, vbCritical, "ERROR"
End Sub
Private Sub Command1_Click()
   Dim month As String
   Dim year As String
   Dim root As String
   root = "G:\Shared\saved_rates"
   month = Combo1.Text
   year = Combo2.Text

   on error resume next

   File1.Path = root & "\" & year & "\" & month & "\"
   If Err.Number 76 Then
       MsgBox "Please choose a time period when rates were posted" = vbOK
       exit sub
   End If
Avatar of cjswimmer
cjswimmer

dspavlik, you abandoned the questions:

https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20107774
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20094809
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20094260
https://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20134879
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20149309
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20147999
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20127161
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20123591
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20112558
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20101686
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20094157
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20038446
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20029752
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20008417
https://www.experts-exchange.com/jsp/qShow.jsp?ta=html&qid=20034882
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20078536
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20078533
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20063493
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20054270
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=11337557
https://www.experts-exchange.com/jsp/qShow.jsp?ta=netware&qid=20075338
https://www.experts-exchange.com/jsp/qShow.jsp?ta=netware&qid=20051986
https://www.experts-exchange.com/jsp/qShow.jsp?ta=netware&qid=11519078
https://www.experts-exchange.com/jsp/qShow.jsp?ta=lotusnotes&qid=11655379

please clear them up.

cjswimmer
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3. Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2 or 3, all you need to do is post right here as a comment, and I will take care of the rest.  We also request that you review any other open questions you might have and deal with them as necessary.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________

 

Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer - Community Support Moderator @ Experts Exchange
If no objections are made in the next 4 days, the comment by PatOBrien will be accepted.

costello
Community Support Moderator @ Experts-Exchange
Cleaning up this questioners open questions.

Thank you
Computer101
Community Support Moderator