very rusty on my VBA, but I am trying to add a new record based on user input. There are text boxes where a person enters in the data, but there are fields within the table that they are not entering. I want to add the new record with SQL statements autofilling data from another table matched on the ID they are entering. I am using a recordset to update the table and have tried putting a sql query directly into addnew which just inputs the text of the query into the table. I have also tried setting the statements into variables with no success.
Set rec = db.OpenRecordset("Select * from Table")
rec.AddNew
rec("A") = Me.A
rec("B") = "SQL1"
rec("C") = "SQL2"
rec("D") = "SQL3"
rec("E") = Me.E
rec("F") = Me.F
rec("G") = Me.G
rec.Update
UPDATE:
Set rec = db.OpenRecordset("Select * from TableA")
rec.AddNew
rec("A") = Me.A
rec("B") = DLookup("B", "TableB", "A=" & Me.A)
rec("C") = DLookup("C", "TableB", "A=" & Me.A)
rec("D") = DLookup("D", "TableB", "D=" & Me.A)
rec("E") = Me.E
rec("F") = Me.F
rec("G") = Me.G
rec.Update
rec.Close