Thanks and it works now. However, is it possible to let the program rememer
the files name so that it can automatically skip the file already been
inputed? FYI, some people might just input the new table into the same
folder, so as I ran the same program again, it read and input the old table
to the production again.
> That is not the real name.
>
[quoted text clipped - 5 lines]
> > Error 3708, The microsoft jet database can not find the input table or query
> > "My AppendQuery"
You would need to create a table that would hold the names of the files that
have been imported and check the table before you do the TransferSpreadsheet.
If you find the name in the table, don't import it. If you don't find the
name, import the file and add the file name to the table.
Sub DoImports
Dim strPath as string
Dim strFileName as string
strPath = "F:\SomeDirectory\"
strFileName = Dir(strPath & "*.xls")
Do While Len(strFileName) <> 0
If IsNull((DLookup("[FileName]", "tblImportedFiles", "[FileName = '"
& strFileName & "'")) Then
DoCmd.TransferSpreadsheet acLink, , "TempTable", strPath &
strFileName, True
CurrentDb.Execute("MyAppendQuery"), dbFailOnError
Docmd.DeleteObject acTable, "TempTable"
CurrentDb.Execute("INSERT INTO tblImportedFiles( [FileName],
[ImportDate] ) Values ('" & strFilename & "', #" & Date & "#);"),
dbFailOnError
End If
strFileName = Dir()
Loop
> Thanks and it works now. However, is it possible to let the program rememer
> the files name so that it can automatically skip the file already been
[quoted text clipped - 11 lines]
> > > Error 3708, The microsoft jet database can not find the input table or query
> > > "My AppendQuery"
Kevin - 18 Jul 2006 20:05 GMT
one more, is it possible to read the files in the sub folders?

Signature
Thanks a lot!
> You would need to create a table that would hold the names of the files that
> have been imported and check the table before you do the TransferSpreadsheet.
[quoted text clipped - 37 lines]
> > > > Error 3708, The microsoft jet database can not find the input table or query
> > > > "My AppendQuery"
Klatuu - 18 Jul 2006 21:36 GMT
You will have to start a new loop with the Dir function using a path name to
the sub directory for each subdirectory.
> one more, is it possible to read the files in the sub folders?
>
[quoted text clipped - 39 lines]
> > > > > Error 3708, The microsoft jet database can not find the input table or query
> > > > > "My AppendQuery"
JIM - 26 Apr 2007 17:52 GMT
> You would need to create a table that would hold the names of the files that
> have been imported and check the table before you do the TransferSpreadsheet.
[quoted text clipped - 37 lines]
> > > > Error 3708, The microsoft jet database can not find the input table or query
> > > > "My AppendQuery"
JIM - 26 Apr 2007 17:56 GMT
I am trying to do the same as mentioned in your response to import excel
tables into access. Here is my code:
Private Sub LoadNewWorkOrders_Click()
Dim strPath As String
Dim strFileName As String
strPath = "C:\Documents and Settings\CMC\New Work Orders\" 'Path to
directory where new w/os are
strFileName = Dir(strPath & "*.xls") 'Dir
function returns only Excel files
Do While Len(strFileName) <> 0 'After Dir
function returns all .xl files, it returns a zero length string ""
If isNull((DLookup("[FileName]","Work Orders","[FileName="' &
strFileName&"'"))Then
DoCmd.TransferSpreadsheet acLink, , "TempTable", strPath & strFileName, True
CurrentDb.Execute ("AppendQuery"), dbFailOnError
DoCmd.DeleteObject acTable, "Temptable"
CurrentDb.Execute("INSERT INTO Work
Orders([Filename],[ImportDate])Values("'&strFilename&'",#"&Date&"#0;"),dbFailOnError
End If
strFileName = Dir()
Loop
End Sub
The if Is Null and the CurrentDb.Execute lines do not compile. I have
something in the syntax wrong but can't find what is wrong. Can you help me
please?
Thanks, JIM
> You would need to create a table that would hold the names of the files that
> have been imported and check the table before you do the TransferSpreadsheet.
[quoted text clipped - 37 lines]
> > > > Error 3708, The microsoft jet database can not find the input table or query
> > > > "My AppendQuery"
snowiii - 27 Feb 2008 19:32 GMT
Hi:
I tried this coding but after importing one file it comes back with an
error, "The database engine could not lock table "tempTable' because it is
already in use by another person or process"....Any suggestions? (Here is
the code)
Sub DoImports_Click()
Dim strPath As String
Dim strFileName As String
'This should be the path to the directory where the spreadsheet files are
strPath = "X:\Tom Snow\Temp\"
'This will cause the Dir function to return only excel files
strFileName = Dir(strPath & "*.xls")
'After the Dir function has returned all the matching file names, it returns
a zero
'length string ""
Do While Len(strFileName) <> 0
'Links to the file name returned by the Dir function. The table name will be
'TempTable
DoCmd.TransferSpreadsheet acLink, , "TempTable", strPath &
strFileName, True
'MyAppendQuery should be the name of the query that read from TempTable and
'Appends the records to your production table
CurrentDb.Execute ("TempTbltoMainTbl"), dbFailOnError
'Deletes the link, but not the file.
DoCmd.DeleteObject acTable, "TempTable"
'Gets the next file name to process
strFileName = Dir()
'Repeats the process until Dir reutrns "" meaning there are no more *.xls
files
Loop
End Sub
> You would need to create a table that would hold the names of the files that
> have been imported and check the table before you do the TransferSpreadsheet.
[quoted text clipped - 37 lines]
> > > > Error 3708, The microsoft jet database can not find the input table or query
> > > > "My AppendQuery"
snowiii - 27 Feb 2008 20:27 GMT
Never mind...I figured out my error...
Thanks!
> Hi:
>
[quoted text clipped - 72 lines]
> > > > > Error 3708, The microsoft jet database can not find the input table or query
> > > > > "My AppendQuery"