I have a form that displays an Item. It has a subform that should show all units with this item, and allow users to add units to the item. I want the subform to show any records, who's item matches the record that the form is currently displaying. TblRollout has a unique field "key" which is a combination of the UnitID and ItemID.
The recordsource for the subform is: "select Unitid, item from tblRollout order by item" It is a dynaset.
I can't find a place to put the code that adds the record without getting the above error. I've tried in the form Before Update, in the textbox Before Update, and lots of other places. The record does actually get added to the table, right before the error appears. I think it has to do with the subform trying to add the record on its own. I'd really appreciate any help you can offer. Thank you!
The code that adds the record is:
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tblrollout", dbOpenDynaset)
With rs
If rs.RecordCount > 0 Then
.MoveLast
End If
.AddNew
!Item = Forms!frmUpdateTests1.txtTestid
!UnitID = Me.[UnitID]
!Key = Trim(Me.UnitID) & "-" & Trim(Forms!frmUpdateTests1.txtTestid)
!Qty = 1
!orddate = Date
.Update
End With
JimD.