So I'm trying to take data from a table, set that piece of data to a variable, and add that variable into a new table. This is the code to access the last name of the person I'm searching for. I'm almost 100% sure this part works.
Dim db As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Set db = CurrentDb()
Set Lrs = db.OpenRecordset("Select [LastName]" & _
"From ['Chromebook Registration Form]" & _
"Where [InventoryNumber] = 1")
dbLastName = Lrs("LastName")
In debug mode, it shows that the variable "dbLastName" contains the string that I want.
However, when I run the following code (to add the information into a new table), I get a 3061 Run-time error code. Too few parameters: expected 1. The debugger says the problem is in the last line. I assume it is a problem with "dbLastName". The timestamp thing works fine.
CurrentDb.Execute " INSERT INTO TempReg " _
& "([Timestamp], LName, FName, Grade, InventoryNumber, SerialNumber, MacAddress, PaidIn, CheckNum) VALUES " _
& "(Now, dbLastName, 'test', 'test', 'test', 'test', 'test', 'test', 'test');"
Thank you!