G
Guest
Using Access 2000 I'm trying to convert excel files to access with this 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]", "tblImportedFiles", "[FileName] = '" &
strFileName & "'")) Then 'If file is not found then enter loop
DoCmd.TransferSpreadsheet acLink, , "WOTempTable", strPath &
strFileName, True 'Link Excel file to Temptable
CurrentDb.Execute ("AppendNewWOs"), dbFailOnError
'Execute AppendQuery
that reads from TempTable and Appends the records to production table
DoCmd.DeleteObject acTable, "WOTemptable"
'Delete link, but not the file
CurrentDb.Execute ("INSERT INTO tblImportedFiles(
[FileName],[ImportDate] ) Values ('" & strFileName & "', #" & Date & "#);"),
dbFailOnError
'Insert file into work orders
End If
strFileName = Dir()
Loop
End Sub
I have a button on my form which calls LoadNewWorkOrders and it hangs up on
line
CurrentDb.Execute ("AppendNewWOs"), dbFailOnError
with a Run-time error 3061
Too few parameters. Expected 12.
Can you tell me what this means? I have searched the knowledge base and not
found anything similar to my problem. Thanks, JIM
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]", "tblImportedFiles", "[FileName] = '" &
strFileName & "'")) Then 'If file is not found then enter loop
DoCmd.TransferSpreadsheet acLink, , "WOTempTable", strPath &
strFileName, True 'Link Excel file to Temptable
CurrentDb.Execute ("AppendNewWOs"), dbFailOnError
'Execute AppendQuery
that reads from TempTable and Appends the records to production table
DoCmd.DeleteObject acTable, "WOTemptable"
'Delete link, but not the file
CurrentDb.Execute ("INSERT INTO tblImportedFiles(
[FileName],[ImportDate] ) Values ('" & strFileName & "', #" & Date & "#);"),
dbFailOnError
'Insert file into work orders
End If
strFileName = Dir()
Loop
End Sub
I have a button on my form which calls LoadNewWorkOrders and it hangs up on
line
CurrentDb.Execute ("AppendNewWOs"), dbFailOnError
with a Run-time error 3061
Too few parameters. Expected 12.
Can you tell me what this means? I have searched the knowledge base and not
found anything similar to my problem. Thanks, JIM