G
Guest
I have a list box were I can select multiple records. A command button is
supposed to add the selected records to an active form with subform. I have
the following code for the button.
Dim varItem As Variant
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("QryOrderDetailsSubform", dbOpenDynaset)
With Me.Products
For Each varItem In .ItemsSelected
rst.AddNew
rst![ProductID] = .ItemData(varItem)
rst![OrderID] = AddanOrderandEditDetails![OrderID]
rst.Update
Next varItem
End With
rst.Close
Set rst = Nothing
The record is added but does not show in the subform because the orderID of
the active record in the form "AddanOrderandEditDetails" is not copied to the
orderID in the record set. What am I doing wrong?
supposed to add the selected records to an active form with subform. I have
the following code for the button.
Dim varItem As Variant
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("QryOrderDetailsSubform", dbOpenDynaset)
With Me.Products
For Each varItem In .ItemsSelected
rst.AddNew
rst![ProductID] = .ItemData(varItem)
rst![OrderID] = AddanOrderandEditDetails![OrderID]
rst.Update
Next varItem
End With
rst.Close
Set rst = Nothing
The record is added but does not show in the subform because the orderID of
the active record in the form "AddanOrderandEditDetails" is not copied to the
orderID in the record set. What am I doing wrong?