Followhyperlink error 490, cannot open specified file.

  • Thread starter Thread starter dan dungan
  • Start date Start date
D

dan dungan

Hi FormsCoders:

The code below returns error 490 on this line:
"K:\Customer Service\Quote\Backup\Data\2008\myFile & .txt"

The file opens if I step through the code using the actual file name
"K:\Customer Service\Quote\Backup\Data\2008\30-027.txt"

In a field FILENAM_, the database holds the file name minus the
extension. In my form, I hold the data in the textbox, txtFilename

I haven't been able to get the proper sytax.

Any suggestions?

Thanks,

Dan


Private Sub Command60_Click()
On Error GoTo Err_Command60_Click
Dim myFile As String
txtFilename.SetFocus
myFile = txtFilename.Text
Application.FollowHyperlink _
"K:\Customer Service\Quote\Backup\Data\2008\myFile & .txt"

Exit_Command60_Click:
Exit Sub

Err_Command60_Click:
MsgBox Err.Description
Resume Exit_Command60_Click

End Sub

Exit_Command60_Click:
Exit Sub

Err_Command60_Click:
MsgBox Err.Description
Resume Exit_Command60_Click

End Sub
 
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
Ok, This seems to open the file without the error.

On Error GoTo Err_Command60_Click
'Dim myFile As String
'txtFilename.SetFocus
'myFile = txtFilename & ".txt"
Application.FollowHyperlink ("K:\Customer Service\Quote\Backup\Data
\2008\" & Me.txtFilename & ".txt")
Exit_Command60_Click:
Exit Sub

Err_Command60_Click:
MsgBox Err.Description
Resume Exit_Command60_Click

End Sub
 
Hi Dan

The problem is that your variable name ("myFile") not its value ("30-027")
is being included in the filename.

In other words, you are looking for a file named "myFile & .txt" instead of
one named "30-027.txt"

Also, if you use the Value property of your textbox (which is the default
property) instead of the Text property, then you don't need to SetFocus to
the textbox.

So, your code should look like this:

Dim myFile As String
myFile = txtFilename.Value ' or just txtFileName
Application.FollowHyperlink _
"K:\Customer Service\Quote\Backup\Data\2008\" & myFile & ".txt"
 
Back
Top