I'm trying to run code that will copy fields into a new table, moving them from a _New
table to the original table. The VBA code that does this works as such:
SQLStatement = CStr("INSERT INTO " & TName & " SELECT * FROM " & TName & "_New")
Log.WriteLine "Running query with string """ & SQLStatement & """ "
QueryTimer = Timer
DoCmd.RunSQL SQLStatement
Log.WriteLine "Query time: " & (Timer - QueryTimer)
The log is just a handful of procedures in a class module I threw together. Its output on the error is
@142921: Running query with string "INSERT INTO Records SELECT * FROM Records_New"
@142941: Error Date/Time: 7/21/2009 2:29:40 PM
@142941: Error # & Description: 3162, You tried to assign the Null value to a variable that is not a Variant data type.
I can confirm that TName
and SQLStatement
are both valid strings at the time the SQL operation is run, and that the sources (Records and Records_New) are both valid. Option Explicit
is set elsewhere in the file to avoid any confusion from typos. The error is thrown on the DoCmd
line.
Why would this have a Null
value, even though DoCmd.RunSQL
doesn't return a value?