My scenario:
1. Items for a job are kept in an items table and are shown in a subform when the job form is opened.
2. When a delivery docket is formed rows from the the items table tblItems are copied to the delivery docket items table tblItemsDD. This way the text can be edited for the delivery docket with changes being made to the original items.
3. Items cannot be added to the delivery docket after creation and of course, this is what they want to be able to do.
This what I am trying:
On the job form I have added this code to the subform enter event:
reccount = sbfItems.Form.Recordset.RecordCount
To the subform exit event I added:
If sbfItems.Form.Recordset.RecordCount > reccount And [DelDocked] Then…..
and it works. In that it only triggers if an item has been added to the list and the job is already flagged as being docketed.
So I have my trigger event working ok.
What I want to do now is read the values from the last (new) record and paste them into a new record in tblItemsDD
I want to do it this way rather than reading from the last file in tblItems as I cannot guarantee it will always be the last item – multi-users
But it dies in the position shown below
If sbfItems.Form.Recordset.RecordCount > reccount And [DelDocked] Then docket = [DDocket] [COLOR=”#FFA07A”]’read from form[/COLOR] jobn = [Job #] [COLOR=”#FFA07A”] ‘read from form[/COLOR] Dim rst As DAO.Recordset Set rst = sbfItems.Form.RecordsetClone rst.MoveLast iid = !ItemID [COLOR=”#0000FF”]<<<<<<<<<<<<<<<<<<<[/COLOR] it dies here with [COLOR="#DAA520"]Compile Error: Invalid or unqualified reference[/COLOR] with [B]!ItemID[/B] highlighted iqty = !ItemQty idesc = !ItemDesc itcost = !ItemCost rst.Close Set rst = Nothing Set rst = CurrentDb.OpenRecordset("tblItemsDD") With rst .AddNew !ItemID = iid !DocketNum = docket !JobNum = jobn !ItemQty = iqty !ItemDesc = idesc !ItemCost = itcost .Update End With rst.Close Set rst = Nothing End if
I can count the records but not read one what am I doing wrong?