Solved

Help converting application.filesearch

Posted on 2007-11-27
3
1,408 Views
Last Modified: 2013-12-05
I had posted this question before, but just found out the solution didn't work.  Here's another attempt...

I am using Access 2007 adp to SQL 2005.  During the conversion, we've discovered that the following code no longer works:
       
'                                    Set FS = Application.FileSearch
'                                    With FS
'                                        F = "S:\MattersClosingDocuments\" & rsImp![CLIENT NUMBER] & rsImp![SubNumber] & rsImp![MATTER NUMBER] & rsImp![Series] & "\EmailAttachmentPost\"
'
'                                       'frmDocumentAttachment_notify
'                                       ChDir F
'
'                                        .LookIn = F
'                                        .FileName = fname
'                                        If .Execute() > 0 Then
'                                            'MsgBox "There were " & .FoundFiles.count & _
'                                                " file(s) found."
'
'                                           fname = Left(fname, Len(fname) - 4) & "_" & z & Right(fname, 4)
'
'                                        Else
'                                            'MsgBox "There were no files found."
'                                        End If
'                                    End With

It was recommended I use this code to replace it, but it does not return the expected results:
Dim iCnt As Integer
                                        Dim tempfname As String
                                        F = "S:\MattersClosingDocuments\" & rsImp![CLIENT NUMBER] & rsImp![SubNumber] & rsImp![MATTER NUMBER] & rsImp![Series] & "\EmailAttachmentPost\"
                                        'f is the path
                                        iCnt = 1
                                        tempfname = Dir(F & "\*.*")
                                        Do While tempfname <> ""
                                            fname = tempfname
                                             fname = Left(fname, Len(fname) - 4) & "_" & z & Right(fname, 4)
                                            iCnt = iCnt + 1
                                            fname = Dir()  '' Get next file
                                        Loop
jumpout:
etc...

Could someone provide a different piece of code to replace the application.filesearch?

Thanks!                                                                        
0
Comment
Question by:dleads
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
What exactly are you trying to accomplish with the FileSearch? Or, better yet, what are you trying to do with the code? It appears you're trying to loop through files and do something... can you explain exactly what you're trying to do?

0
 

Author Comment

by:dleads
Comment Utility
I've just taken over this code...

What it appears to be is looking for the names of files in a folder and counting them.
0
 

Author Closing Comment

by:dleads
Comment Utility
I'm closing the message due to lack of time to address it.  I appreciate your attempt to help and therefore am awarding the points.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now