Discuss Add Records Using SQL in VBA in the SQL Basics forum on Tutorialized. Add Records Using SQL in VBA SQL Basics forum covering the Structured Query Language standard. SQL is a common language recognized by many RDBMS software packages, that is designed to be a robust method for addressing the data stored in a database.
Time spent in forums: 6 m 48 sec
Reputation Power: 0
Add Records Using SQL in VBA
I have an Access DB with two tables, oakland_county_meetings and 20151005
I want to add only new records from 20151005 to oakland_county_meetings and have the following code:
Public Function AddRecords1() As String
Dim TableToAdd As String
Dim MainTableName As String
MainTableName = "oakland_county_meetings"
TableToAdd = "20151005" 'InputBox("Name of table?")
Dim strSQL As String
strSQL = "INSERT INTO MainTableName " & _
"SELECT TableToAdd.* " & _
"FROM TableToAdd " & _
"LEFT JOIN ON TableToAdd.nationbuilder_signup_id = MainTableName.nationbuilder_signup_id " & _
"WHERE MainTableName.nationbuilder_signup_id IS NULL;"
I get "syntax error in FROM clause and am stumped.
Thanks in advance for any help.