Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run_Time '490' Error Message 1

Status
Not open for further replies.

edsearl

Programmer
May 8, 2002
24
0
0
US
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
 
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
 
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
 
Thank you Lewds
You put me on the right track.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top