I am trying to create a set of records in tblPayments based on the the records in qryBudget. The two tables are related by cost code. I am creating a command button on a form (based on the billing period of the payments) to run this expression. I want to create the records using the "billingperiodno" from the form and the "cost code" from the query.
This is what I have come up with so far:
For Each CostCode In qryBudget
DoCmd.RunSQL "INSERT INTO tblPayments (CostCode,ActualCost,ProjectedCost, BillingPeriodNo, Contract) VALUES ('" & qryBudget.CostCode & "', 0, 0,Me.BillingPeriodNo,'N/A');"
Next CostCode
But this gives me a type mismatch and expected variable errors. I think this is the right track, but my syntax is all wrong. I would appreciate any help.
This is what I have come up with so far:
For Each CostCode In qryBudget
DoCmd.RunSQL "INSERT INTO tblPayments (CostCode,ActualCost,ProjectedCost, BillingPeriodNo, Contract) VALUES ('" & qryBudget.CostCode & "', 0, 0,Me.BillingPeriodNo,'N/A');"
Next CostCode
But this gives me a type mismatch and expected variable errors. I think this is the right track, but my syntax is all wrong. I would appreciate any help.