Search code examples
sqlms-accessvbajet

Inserting variable along with data from select


I have a query that currently inserts data from one table into another table,

moveQuery = "INSERT INTO results(ClassCode, AttemptDate, StudentID, Mark) 
SELECT F1,F2,F3,F4 FROM " & randtablename & " where F1 = '" & classcode & "'"

I'd like to insert an extra column from a variable while doing so.

How can I do this in Microsoft Access VBA?


Solution

  • INSERT INTO results(ClassCode, AttemptDate, StudentID, Mark, Other_column) 
    SELECT F1,F2,F3,F4, 'extraVariable'
    FROM ...