Re: Please Help with database upate. New to database
- From: pietlinden@xxxxxxxxxxx
- Date: 20 Jul 2006 22:20:43 -0700
OdAwG wrote:
Works like a charm, thanks for the expert advice.the way I would handle it is something like this:
I'm so sorry to ask you another question, you've been such a great help,
however, is there a way to automatically import text/excel files into Access
tables or query. what I would like to do is when I launch my database, it
would automatcially import the text files or excel files.
Argus
1. create import specifications for your text files.
2. Always put the files to be imported into the same folder.
'---code these---
3. loop through the contents of the folder (from step 2), and import
the files.
4. any files successfully imported should be moved to a different
folder. (use Rename) The failed ones should go in another folder.
Sorry, getting brain damage... this is most of it... I've commented out
the parts that aren't working yet. Oh, the BrowseFolder API... that's
here:
http://www.mvps.org/access/api/api0002.htm
Here's my code so far...
Public Sub ImportFilesInDirectory(ByVal strExtension As String)
Dim strOriginalPath As String
Dim strFinalPath As String
Dim strFinalFile As String
Dim myFile As String
strOriginalPath = BrowseFolder("Select a folder to process")
strFinalPath = BrowseFolder("Select a folder to move processed
files to:")
myFile = Dir(strOriginalPath & "\*." & strExtension)
strFinalPath = strFinalPath & "\" & myFile
'---Loop through the files in the folder (strPath)
Do While myFile <> ""
'---handle Text and Excel files differently...
If strExtension = "txt" Then
DoCmd.TransferText acImportDelim, "MySpecificationName",
"DestinationTable", myFile, False
'Name "c:\origfile.txt" As "c:\newfile.txt" <---NEEDS
REPAIR
ElseIf strExtension = "xls" Then
DoCmd.TransferSpread*** acImport,
acSpreadsheetTypeExcel9, "DestinationTable", myFile, True
End If
'---run the "move file" code here...
myFile = Dir
Loop
End Sub
.
- References:
- Please Help with database upate. New to database
- From: OdAwG
- Re: Please Help with database upate. New to database
- From: pietlinden
- Re: Please Help with database upate. New to database
- From: OdAwG
- Re: Please Help with database upate. New to database
- From: pietlinden
- Re: Please Help with database upate. New to database
- From: OdAwG
- Re: Please Help with database upate. New to database
- From: pietlinden
- Re: Please Help with database upate. New to database
- From: OdAwG
- Please Help with database upate. New to database
- Prev by Date: Re: Openrecordset with criteria problem
- Next by Date: Re: Suggestions for software for mass emailing
- Previous by thread: Re: Please Help with database upate. New to database
- Next by thread: IMPORTING Question
- Index(es):