Importing Data with Update Query



Hi Please help.

This below is my current import code for linking an excel spreadsheet into a
table and running an append query. I am looking to get rid of the append
query and write as an sql in the import code an update query that will update
from another table into my temp table.
Private Sub cmdLoadData_Click()
strPath = "\\w2k6001\data\NCHO\Housing Services\Data Warehouse\Weekly
CSAT Report\"
strFileName = Dir(strPath & "NPSReport.xls")
strTempTable = "tblAddressTemp"
MsgBox "Data Loading...", vbInformation
If Len(strFileName) <> 0 Then
DoCmd.TransferSpreadsheet acLink, , strTempTable, strPath &
strFileName, True
CurrentDb.Execute ("qappAddress"), dbFailOnError
DoCmd.DeleteObject acTable, strTempTable
End If
MsgBox "Import Complete", vbInformation
End Sub



Stored queries execute faster than in line queries. It would actually be
better to create your update query and use it just as you are the append
query. If, however, you want to use VBA, it would be something like:

CurrentDb.Execute("your sql code here"), dbFailOnError

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question