Getting Error w Dir Function

T

Ted

Hi all,

I'm running an Access 2000 database...soon to be Access 2007. I'm running
code to look on our server to see if a file exists. If it doesn't it creates
the file. It works ok but for some reason at the end it opens up a dialog
box and tells me "Unable to open [filename]. The hyperlink cannot be
followed to the destination." if the file has to be created Why when I run
this to I get that dialog box at the end? Any help would be very much
appreciated. I'm stumped.

Dim Response, objWord
On Error GoTo Err_cmdNewLossAssignment_Click

If Len(Dir("L:/CLAIMS/NewLossAssignments/" &
Forms![frmRCAClaims]![1#_CLM#] & "NLA.doc")) > 0 Then
cmdNewLossAssignment.HyperlinkAddress =
"L:/CLAIMS/NewLossAssignments/" & Forms![frmRCAClaims]![1#_CLM#] & "NLA.doc"
Else
Response = (MsgBox("There were no New Loss Assignments found
associated with this Claim. Would you like to create a New Loss Assignment
called " & Forms![frmRCAClaims]![1#_CLM#] & "NLA.doc?", 4, "No file found"))
If Response = vbYes Then
Set objWord = CreateObject("Word.Application")
objWord.Application.Visible = True
objWord.Documents.Add
CODE
objWord.ActiveDocument.SaveAs
filename:="L:/CLAIMS/NewLossAssignments/" & Forms![frmRCAClaims]![1#_CLM#] &
"NLA.doc"
Set objWord = Nothing
End If
End If

Exit_cmdNewLossAssignment_Click:
Exit Sub

Err_cmdNewLossAssignment_Click:
MsgBox Err.Description
Resume Exit_cmdNewLossAssignment_Click
End Sub
 
B

boblarson

Well, for one thing (don't know if it is your whole problem) your file naming
should use BACK SLASHES (\) and not forward slashes (/) for files on a
computer. Forward slashes are for URLs not file names.

Also, you really shouldn't use the # sign in file names.
--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top