Hi to all,
I am using a command button to insert records in a table. I have the following VBA code:
Code:
Dim intVal1 as Integer
Dim intVal2 as Integer
....
strSQL = "Insert INTO Table1 " _
& "(field1,field2, field3, field4, field5, field6) " _
& "SELECT field1, field2, field3, field4, intVal1, intVal2 " _
& "FROM Table2 INNER JOIN Table3 ON Table2.pk = Table1.fk " _
& "WHERE Condition1 AND Condition2 AND Condition3;"
db.Execute strSQL, dbFailOnError
intVal1 and intVal2 are numbers taken from a different table: Table4 as follow:
Code:
intVal1 = DLookUp("[FieldName1]", "[Table4]", "Criteria")
intVal2 = DLookUp("[FieldName2]", "[Table4]", "Criteria")
Using Debug.Print shows the correct numbers for intVal1 and intVal2.
Running the code gives error 3061: Too few parameter. Expected 2.
Any ideas?
Thanks,
Kahlil