Scenario:
Main Form: fMain
Sub Form: fsub1 and fsub2
2 tables: tbl1 and tbl2
Query: qryAppendtbl2
After 2 fields are chosen on fMain, fsub1 will display an ID that is indexed into tbl1. fsub2 needs that index number from fsub1 so the records can be synched in reports. NO record exists on tbl2 I am trying to create the record using the forms and an append query.
I can create an append query (qryAppendtbl2) to get the ID from fsub1 and append tbl2, however I cannot get the code correct using VBA. I am using the following code and I get an error that states "Too few parameters. Expected 1" and the compiler highlights the last line:
Private Sub SQE_AfterUpdate()
Dim strSql As String
strSql = "INSERT INTO tbl2 ( InfoID, PO_NUM, PO_ITM ) SELECT tbl1.InfoID, tbl1.PO_NUM, tbl1.PO_ITM From tbl1 GROUP BY tbl1.InfoID, tbl1.PO_NUM, tbl1.PO_ITM HAVING (((tbl1.InfoID)=[Forms]![fMain]![fsub1]![ID]));"
DBEngine(0)(0).Execute strSql, dbFailOnError
End Sub
Can anybody help me? I know only enough VBA to be dangerous. Thanks.
Main Form: fMain
Sub Form: fsub1 and fsub2
2 tables: tbl1 and tbl2
Query: qryAppendtbl2
After 2 fields are chosen on fMain, fsub1 will display an ID that is indexed into tbl1. fsub2 needs that index number from fsub1 so the records can be synched in reports. NO record exists on tbl2 I am trying to create the record using the forms and an append query.
I can create an append query (qryAppendtbl2) to get the ID from fsub1 and append tbl2, however I cannot get the code correct using VBA. I am using the following code and I get an error that states "Too few parameters. Expected 1" and the compiler highlights the last line:
Private Sub SQE_AfterUpdate()
Dim strSql As String
strSql = "INSERT INTO tbl2 ( InfoID, PO_NUM, PO_ITM ) SELECT tbl1.InfoID, tbl1.PO_NUM, tbl1.PO_ITM From tbl1 GROUP BY tbl1.InfoID, tbl1.PO_NUM, tbl1.PO_ITM HAVING (((tbl1.InfoID)=[Forms]![fMain]![fsub1]![ID]));"
DBEngine(0)(0).Execute strSql, dbFailOnError
End Sub
Can anybody help me? I know only enough VBA to be dangerous. Thanks.