473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

FileSearch not working in Access 2003

I have recently converted an Access 97 database to Access 2003.
However, I am running into a problem with using
Application.Filesearch
to locate a file in my directory. The code follows:

-------------------------------
Dim dbDir As String 'Directory where database stored
Dim dbPath As String 'Directory + Name of database
Dim dbFileName As String 'Name of the database
Dim Card1File As String 'Text file to hold Card 1 data
Dim Card2File As String 'Text file to hold Card 2 data
Dim Card3File As String 'Text file to hold Card 3 data
Dim PAAFile As String 'The resulting file created
from
export
Dim fs As Variant 'File Search variable
'Retrieve the database path and database name and directory
dbPath = CurrentDb.Name
dbFileName = Dir(dbPath)
dbDir = Left(dbPath, Len(dbPath) - Len(dbFileName))
'Create the Pesticide text file names
Card1File = dbDir & "PAACard1.txt"
Card2File = dbDir & "PAACard2.txt"
Card3File = dbDir & "PAACard3.txt"
'Create final text file by appending julian day to the file name
"PAA200"
PAAFile = dbDir & "paa200." & DatePart("y", Now())
'Export the data from tables PestCard1, PestCard2, PestCard3 into
the 3 text
'files. These 3 text files will then be joined into 1 file.
DoCmd.TransferText acExportFixed, "PestCard1 Export Specification",
_
"PestCard1", Card1File, False, ""
DoCmd.TransferText acExportFixed, "PestCard2 Export Specification",
_
"PestCard2", Card2File, False, ""
DoCmd.TransferText acExportFixed, "PestCard3 Export Specification",
_
"PestCard3", Card3File, False, ""
'Set File search parameter to look for output file name
Set fs = Application.FileSearch
fs.FileName = PAAFile
'if output file is found, append data from the three text files to
the
'end of the current file. "/b" is added as a command line option to
'prevent EOF character from being copied to the file
If fs.Execute 0 Then
Call Shell(Environ$("COMSPEC") & " /c copy """ & PAAFile & """ +
""" & _ Card1File & """ + """ & Card2File & """ + """ & Card3File &
_
""" """ & PAAFile & """ /b ", vbHide)
'Output file is not found, so Concatenate the 3 text files into one
file
Else
Call Shell(Environ$("COMSPEC") & " /c copy """ & Card1File & _
""" + """ & Card2File & """ + """ & Card3File & """
""" & _
PAAFile & """ /b ", vbHide)
End If
------------------------------------------------------
The filesearch is not finding the file as it should. Has there been
a
change with how this works in Access 2003? This worked perfectly in
A97.
Thanks in advance for any help!!!

Feb 12 '07 #1
2 7299
IME, FileSearch is not reliable. It works inconsistently across different
versions of Windows, and doesn't find all file types (such as zip files.) It
has been removed from Access 2007.

For an alternative, see:
List files recursively - List files in a folder and subfolders
at:
http://allenbrowne.com/ser-59.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<st***********@ncmail.netwrote in message
news:11*********************@a34g2000cwb.googlegro ups.com...
>I have recently converted an Access 97 database to Access 2003.
However, I am running into a problem with using
Application.Filesearch
to locate a file in my directory. The code follows:

-------------------------------
Dim dbDir As String 'Directory where database stored
Dim dbPath As String 'Directory + Name of database
Dim dbFileName As String 'Name of the database
Dim Card1File As String 'Text file to hold Card 1 data
Dim Card2File As String 'Text file to hold Card 2 data
Dim Card3File As String 'Text file to hold Card 3 data
Dim PAAFile As String 'The resulting file created
from
export
Dim fs As Variant 'File Search variable
'Retrieve the database path and database name and directory
dbPath = CurrentDb.Name
dbFileName = Dir(dbPath)
dbDir = Left(dbPath, Len(dbPath) - Len(dbFileName))
'Create the Pesticide text file names
Card1File = dbDir & "PAACard1.txt"
Card2File = dbDir & "PAACard2.txt"
Card3File = dbDir & "PAACard3.txt"
'Create final text file by appending julian day to the file name
"PAA200"
PAAFile = dbDir & "paa200." & DatePart("y", Now())
'Export the data from tables PestCard1, PestCard2, PestCard3 into
the 3 text
'files. These 3 text files will then be joined into 1 file.
DoCmd.TransferText acExportFixed, "PestCard1 Export Specification",
_
"PestCard1", Card1File, False, ""
DoCmd.TransferText acExportFixed, "PestCard2 Export Specification",
_
"PestCard2", Card2File, False, ""
DoCmd.TransferText acExportFixed, "PestCard3 Export Specification",
_
"PestCard3", Card3File, False, ""
'Set File search parameter to look for output file name
Set fs = Application.FileSearch
fs.FileName = PAAFile
'if output file is found, append data from the three text files to
the
'end of the current file. "/b" is added as a command line option to
'prevent EOF character from being copied to the file
If fs.Execute 0 Then
Call Shell(Environ$("COMSPEC") & " /c copy """ & PAAFile & """ +
""" & _ Card1File & """ + """ & Card2File & """ + """ & Card3File &
_
""" """ & PAAFile & """ /b ", vbHide)
'Output file is not found, so Concatenate the 3 text files into one
file
Else
Call Shell(Environ$("COMSPEC") & " /c copy """ & Card1File & _
""" + """ & Card2File & """ + """ & Card3File & """
""" & _
PAAFile & """ /b ", vbHide)
End If
------------------------------------------------------
The filesearch is not finding the file as it should. Has there been
a
change with how this works in Access 2003? This worked perfectly in
A97.
Thanks in advance for any help!!!
Feb 13 '07 #2
On Feb 12, 8:08 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
IME, FileSearch is not reliable. It works inconsistently across different
versions of Windows, and doesn't find all file types (such as zip files.) It
has been removed from Access 2007.

For an alternative, see:
List files recursively - List files in a folder and subfolders
at:
http://allenbrowne.com/ser-59.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<stuart.med...@ncmail.netwrote in message

news:11*********************@a34g2000cwb.googlegro ups.com...
I have recently converted an Access 97 database to Access 2003.
However, I am running into a problem with using
Application.Filesearch
to locate a file in my directory. The code follows:
-------------------------------
Dim dbDir As String 'Directory where database stored
Dim dbPath As String 'Directory + Name of database
Dim dbFileName As String 'Name of the database
Dim Card1File As String 'Text file to hold Card 1 data
Dim Card2File As String 'Text file to hold Card 2 data
Dim Card3File As String 'Text file to hold Card 3 data
Dim PAAFile As String 'The resulting file created
from
export
Dim fs As Variant 'File Search variable
'Retrieve the database path and database name and directory
dbPath = CurrentDb.Name
dbFileName = Dir(dbPath)
dbDir = Left(dbPath, Len(dbPath) - Len(dbFileName))
'Create the Pesticide text file names
Card1File = dbDir & "PAACard1.txt"
Card2File = dbDir & "PAACard2.txt"
Card3File = dbDir & "PAACard3.txt"
'Create final text file by appending julian day to the file name
"PAA200"
PAAFile = dbDir & "paa200." & DatePart("y", Now())
'Export the data from tables PestCard1, PestCard2, PestCard3 into
the 3 text
'files. These 3 text files will then be joined into 1 file.
DoCmd.TransferText acExportFixed, "PestCard1 Export Specification",
_
"PestCard1", Card1File, False, ""
DoCmd.TransferText acExportFixed, "PestCard2 Export Specification",
_
"PestCard2", Card2File, False, ""
DoCmd.TransferText acExportFixed, "PestCard3 Export Specification",
_
"PestCard3", Card3File, False, ""
'Set File search parameter to look for output file name
Set fs = Application.FileSearch
fs.FileName = PAAFile
'if output file is found, append data from the three text files to
the
'end of the current file. "/b" is added as a command line option to
'prevent EOF character from being copied to the file
If fs.Execute 0 Then
Call Shell(Environ$("COMSPEC") & " /c copy """ & PAAFile & """ +
""" & _ Card1File & """ + """ & Card2File & """ + """ & Card3File &
_
""" """ & PAAFile & """ /b ", vbHide)
'Output file is not found, so Concatenate the 3 text files into one
file
Else
Call Shell(Environ$("COMSPEC") & " /c copy """ & Card1File & _
""" + """ & Card2File & """ + """ & Card3File & """
""" & _
PAAFile & """ /b ", vbHide)
End If
------------------------------------------------------
The filesearch is not finding the file as it should. Has there been
a
change with how this works in Access 2003? This worked perfectly in
A97.
Thanks in advance for any help!!!- Hide quoted text -

- Show quoted text -
Thanks for your help!!!

Feb 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: andybriggs | last post by:
Hi all, Two machines out of eight that are running an A97 database stored on a server are generating an "Invalid Procedure Call or Argument" error when encountering the .Filename property of...
3
by: Wilson Tan | last post by:
Has anybody encountered any problem with the Execute method or FilesFound property of the FileSearch object in Access 2002? I have this short routine that searches for a specific file that I'm...
1
by: Mark | last post by:
Can anyone please tell me why the following code works fine in Win98/Access97, but fails to recognize files with a ".zip" extension in WinXP/Access2002/2000? It correctly lists the name of each...
1
by: | last post by:
Hi I am using Filesearch to find a list of files in a directory, and then to take the data and put it into an Access database. The code was working well within VBA and I have ported it into VB6,...
7
by: Brent McIntyre | last post by:
Good evening all, I am writing a program which requires me to search for files as I have done many times in Microsoft Excel Visual Basic for Applications, as per below. Set fs =...
19
by: Alan Carpenter | last post by:
Access 8 on Win98 and WinXP I'm having trouble with wildcards in the .Filename property of the FileSearch Object giving different results on win98 and XP. I've been successfully using...
22
tdw
by: tdw | last post by:
We just added a new login name in our server for a girl named Courtney. She is using a computer that I used to use. The following code in our Orders Database has alway worked fine, but when she is...
2
by: Dammato | last post by:
my access-application, I have a selection of "word"-documents. I want to look for a word/string within these documents and make a smaller selection with only those documents that contain that...
3
by: MLH | last post by:
With Application.FileSearch .NewSearch .LookIn = "C:\My Documents" .SearchSubFolders = True .FileName = "Run" .MatchTextExactly = True .FileType = msoFileTypeAllFiles End With My code pukes...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.