Private Sub cmdInsertassmt_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String, strSQLInsert As String
Set dbs = CurrentDb
Set rst = Me.frmInternationalAssortments.Form.RecordsetClone
strSQL = "Select ProductID, Quantity FROM tblAssortments WHERE AssortmentID = '" & Me!frmInternationalAssortments.Form!txtAssortmentID & "'"
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveFirst
Do Until rst.EOF
strSQLInsert = "INSERT INTO [tblInternationalOrderDetails] " & _
"(OrderID, ProductID, Quantity) SELECT " & Me!OrderID & ", " & _
rst!ProductID & ", " & rst!Quantity * Me.txtDefaultQty
CurrentDb.Execute strSQLInsert, dbFailOnError
rst.Edit
rst.Update
rst.MoveNext
Loop
Set dbs = Nothing
Set rst = Nothing
Me!sbfInternationalOrderDetails.Requery
Me!sbfInternationalOrderDetails.SetFocus
DoCmd.GoToRecord , , acNewRec
Me!sbfInternationalTotals.Requery
End Sub
|