Solved

Help converting application.filesearch

Posted on 2007-11-27
3
1,415 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
ID: 20377922
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
ID: 20378055
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
ID: 31411283
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

830 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