File Path Not Found

dr223

Registered User.
Local time
Today, 15:39
Joined
Nov 15, 2007
Messages
219
Hi,

I had an application developed with another developer in Access 2003, our company has upgraded our laptops to Microsoft Office 2010 and now when I open a form (frm_Enq_Address_Dialog) I receive an error on Form load as
"File Path not Found (You entered an expression that has an invalid reference to th eproperty FileSearch)"

As noted, this appeared when Access was upgraded to Access2010 in our laptops - I believe the code that causes this error is below;

Code:
Private Sub Form_Timer()
    If XRefUpdate = 1 Then
    Else
        DoCmd.Hourglass True
        XRef.Requery
        XRef2.Requery
        XRef3.Requery
        XRefUpdate = 1
        Wait = vbNullString
        Job.Visible = True
        CoName.Visible = True
        Line1.Visible = True
        Line2.Visible = True
        Town.Visible = True
        [County/Country].Visible = True
        PostCode.Visible = True
        Contact.Visible = True
        If DLookup("KeyWordIDNo", "tbl_Enquiry_Details", "QueryID =" & QueryIDNo) = 16 Then
            KeyWord.ForeColor = 255
        End If
 
        Call Search
        'HYPERLINK
        With lblAppendix
            If DLookup("MediaIDNo", "tbl_Enquiry_Details", "QueryID =" & QueryIDNo) = 2 Then
                If AttachST = 1 Then
                    .HyperlinkAddress = AttachmentPath & Fname
                    .Caption = "Fetch.Appendix@" & Fname
                    .ForeColor = 16711680
                    .BackColor = 16777215
                Else
                    .HyperlinkAddress = vbNullString
                    .Caption = "Attachment is not available!"
                    .ForeColor = 16777215
                    .BackColor = 255
                End If
            Else
                .Visible = False
            End If
        End With
 
        TimerInterval = 0
        DoCmd.Hourglass False
    End If
End Sub

Code:
Sub Search()
    AttachST = 0
    AttachmentPath = DLookup("txtFilePath3", "tbl_FilePath")
 
    Fname = DLookup("EnquiryRef", "tbl_Enquiry_Details", "QueryID =" & QueryIDNo) & ".rtf"
    Search2
    If AttachST = 1 Then
        Exit Sub
    End If
    Fname = DLookup("EnquiryRef", "tbl_Enquiry_Details", "QueryID =" & QueryIDNo) & ".txt"
    Search2
    If AttachST = 1 Then
        Exit Sub
    End If
    Fname = DLookup("EnquiryRef", "tbl_Enquiry_Details", "QueryID =" & QueryIDNo) & ".htm"
    Search2
    If AttachST = 1 Then
        Exit Sub
    End If
End Sub

Code:
Sub Search2()
On Error GoTo Search_Err
    Dim strPrompt As String, strTitle As String
 
 
    ChDir AttachmentPath   ' Changes directory to new file path
 
    Dim i As Integer
   [B] With Application.FileSearch[/B]
        .LookIn = AttachmentPath
        .FileName = Fname
        If .Execute > 0 Then
            AttachST = 1
        Else
            AttachST = 0
            Exit Sub
        End If
    End With
Search_Exit:
    Exit Sub
Search_Err:
   [B]MsgBox "File Path Not Found (" & Error$ & ")", vbInformation, vbNullString[/B]
    Resume Search_Exit
End Sub

Any help highly appreaciated...
Thank you
 
Last edited:
Now all you need to do is highlight the Line Of Code that causes the problem. :rolleyes:
 
At run time - when I open the form (frm_Enq_Address_Dialog) - A message box comes up with teh message;

"File Path not Found (You entered an expression that has an invalid reference to the property FileSearch)"

I clicked Ok - same message came up - Clicked Ok same message came up

(3 times before it disappered).

Then on the lblAppendix (Caption: Hyperlink) is changed to

"Attachment is not avaialble!" and highlighted in RED

Now why this happens as so...
Thanks
 
Ah ! Apparently FileSearch method was taken off in Access 2007, explains why its not available on my Access. ;)

Did a quick Google Search : SydneyGeek has some "alternatives", hope this helps.
 
Ah ! Apparently FileSearch method was taken off in Access 2007

Any way round it ?

Thanks
 
If you follow the link I posted in my earlier post, you would find some alternatives in the reply posts.. The links Sydney provided does not exist anymore (that's a bummer, as normally they are very good).
some "alternatives", hope this helps.
 
Ok - How can i use the Dir method / vb code directing to the code;

Code:
Sub Search2()
On Error GoTo Search_Err

    Dim strPrompt As String, strTitle As String
    
    
    ChDir AttachmentPath   ' Changes directory to new file path
                       
    Dim i As Integer
    With Application.FileSearch
        .LookIn = AttachmentPath
        .FileName = Fname
        If .Execute > 0 Then
            AttachST = 1
        Else
            AttachST = 0
            Exit Sub
        End If
    End With

Search_Exit:
    Exit Sub

Search_Err:
    MsgBox "File Path Not Found (" & Error$ & ")", vbInformation, vbNullString
    Resume Search_Exit

End Sub

Many thanks
 
Okay, lets start over. What I offered you was alternatives to some functionality that was deprecated. Since I have no idea of what you are doing, how about you explain what you want to do in plain English.
 
Ok my friend- this is not an application I developed my self.

Those where its thrown to you resolve before end of week thingy.

The guy who developed this seemed to have used the Application.FileSearch - as you noticed is the root of the problem thank you for that..

Now, I need to replace the Application.FileSearch to perform similar function..

Any help please
 

Users who are viewing this thread

Back
Top Bottom