Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for specific text file

Status
Not open for further replies.

awhitsel

Programmer
Feb 22, 2001
80
US
I am currently writing an application for importing text files into an Access database using import specifications.

I wait to be able to do the following:
1. Allow the user to enter the name of the text file, with the full file location, folders and all.
2. Split the file into two parts since the data will be of verying lengths (this part I've already accomplished).
3. Search in the specified folder for the newly-split files
a. If the file exists, import the text file into the database using the import specification prescribed for that particular file
b. If the file does not exist, go to the next part of the code and search for the next file, and keep doing this until all of the required files have been imported.

Is this possible?

Please adivse. Thanks.
 
1. The best way to do this is to use the OpenFile dialog box that is used by every other program. There are many ways to get a dialog box. I'm running Access 97, so I know of only one good way. Here it is:

Using an API call (the best way for older versions of Access):
Standard file dialog:
Browse For Folder dialog:


3. - You can use the FileSystem object to check if a file exists, delete files, etc. For your purpose, you might use:

[tt]If FileSystem.Dir(strPathAndFilename) <> "" Then
'file exists
End If[/tt]
 
I'm using Access 2002. Will this work for what I'm using now?
 
It will definitely work, but I think there's an even easier way for Access2002.

Unfortunately, I don't know the exact command to get the OpenFile dialog. It might be under Application.OpenFile or something like that. Anyone else know?

Ahh, Google. You're going to have to get the details yourself, but this is a start:

Code:
Function TestFile()
    Dim fd As FileDialog
    Dim lng As Long

    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    fd.Show
    For lng = 1 To fd.SelectedItems.Count
        Debug.Print fd.SelectedItems.Item(lng)
    Next
    Set fd = Nothing
End Function

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top