×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Run_Time '490' Error Message

Run_Time '490' Error Message

Run_Time '490' Error Message

(OP)
This coding looks for a drawing in one folder. If it can't find it there it produces an error which sends it to
err_drawing to look in the other folder. If it can't find it in the second folder it produces a Run-time '490' message box.

In place of the Run-time message box I would like it to display one that just says that it can't find the drawing.

Private Sub Drawing_DblClick(Cancel As Integer)
 Dim strinput As String
 Dim Drawing As String
 
 On Error GoTo err_drawing
    If IsNull(SupplyVoltage) Then GoTo exit_Drawing_DblClick

    If [SupplyVoltage] = 36.5 Then
     strinput = "F:\NR-Scanned-Drawings\Customer Connection CD\Overhead\33kV Customer-OH\" & Me("drawing") & ".tif"
    End If    
          
     Application.FollowHyperlink strinput, , True
     
exit_Drawing_DblClick:
    Exit Sub
    
err_drawing:

   If [SupplyVoltage] = 36.5 Then
     strinput = "F:\NR-Scanned-Drawings\Customer Connection CD\Underground\33kV Customer-UG\" & Me("drawing") & ".tif"
    End If
    
    
    Application.FollowHyperlink strinput, , True
    
End Sub

RE: Run_Time '490' Error Message

Hi.....

According to your code, it atempts to follow a hyperlink in any case.

You should alter your code to assign the variable strinput with the Dir command, then test the variable.

If strinput returns a filename then follow with the hyperlink command.

As example

    strinput = Dir("C:\YourFile") 'get file
    If strinput = "" Then 'file exist?
        strinput = Dir("C:\Temp\YourFile")' get file in another dir
    End If
    
    If strinput = "" Then 'file exist?
        MsgBox "File does not exsist", vbOKOnly, "FILE WARNING"
    Else
        Application.FollowHyperlink  strinput, True
    End If



Hope this helps

RE: Run_Time '490' Error Message

Ooops..

you will have to add the file path in the hyperlink command.

strinput = Dir(Yourfile) will only return the Filename

Should be something like

strPathStart1 = "F:\NR-Scanned-Drawings\Customer Connection CD\Overhead\33kV Customer-OH\"

strPathStart2 = "F:\NR-Scanned-Drawings\Customer Connection CD\Overhead\33kV Customer-UG\"

strPathEnd = ".tif"

TheFile = strPathStart1 & strinput & strPathEnd

Application.FollowHyperLink TheFile,,True

RE: Run_Time '490' Error Message

(OP)
Thank you Lewds
You put me on the right track.

RE: Run_Time '490' Error Message

(OP)
I did this

If [Supply Voltage] = 36.5 Then
     strinput = Dir("F:\NR-Scanned-Drawings\Customer Connection CD\Overhead\33kV Customer-OH\" & Me("drawing") & ".tif")
        If strinput <> "" Then
        strinput = "F:\NR-Scanned-Drawings\Customer Connection CD\Overhead\33kV Customer-OH\" & Me("drawing") & ".tif"
        Application.FollowHyperlink strinput, , True
        Exit Sub
        Else
            strinput = Dir("F:\NR-Scanned-Drawings\Customer Connection CD\Underground\33kV Customer-UG\" & Me("drawing") & ".tif")
        End If
        If strinput <> "" Then
        strinput = "F:\NR-Scanned-Drawings\Customer Connection CD\Underground\33kV Customer-UG\" & Me("drawing") & ".tif"
        Application.FollowHyperlink strinput, , True
        Exit Sub
        Else
            MsgBox "File does not exist", vbOKOnly, "File Warning"
            Exit Sub
                  
        End If

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close