-1
我想在VBA宏中運行這條SQL語句,但由於某種原因,由於語法錯誤,我無法找到它,所以它不會運行。我對VBA相當陌生,所以任何幫助指出這個錯誤將不勝感激。SQL語句中的語法錯誤(2)
Dim dte As String, db As Database, tableName As String, DataDump As Recordset, clientTable As Recordset
Set db = CurrentDb
dte = InputBox("What date was the Data Dump run?", "Please Input a date")
tableName = "FN_DataDump_ALL_" & dte
Set DataDump = db.OpenRecordset(tableName, dbOpenDynaset, dbEditAdd)
Set clientTable = db.OpenRecordset("Clients", dbOpenDynaset, dbEditAdd)
MySQL = "SELECT DISTINCT DD.[Client ID] " & _
"INTO Clients " & _
"FROM " & tableName & "as DD " & _
"Where CL.[Client ID] NOT IN (SELECT DD.[Client ID] ""FROM"" & tableName & ""as DD"") "
db.Execute MySQL
謝謝!還有一件事,如果表已經存在,我可以'SELECT ... INTO'嗎? – William 2014-12-02 19:01:05
在這種情況下,您將使用INSERT INTO。 – 2014-12-02 19:03:57
所以我只是將'SELECT'改爲'INSERT'? – William 2014-12-02 19:04:54