let's say you have this data set:
Code:
RecordID PersonID ItemID
1 1 1
2 1 1
3 1 1
4 1 2
Let's assume for the sake of this question that this is the only data you have. When you go to the data entry form for record 5 (the new record) do you want the ITEMID to be filled in with 2 (the most recent ITEMID) OR do you want it to be 1 (the most used ITEMID) your last post made it muddy to me.
In either case it can be handled on your data entry form. In the ON ENTER property of your ITEMID field you could have this code:
Code:
Dim db As Database
Dim rst As Recordset
Dim ssql As String
If ItemID = 0 Or IsNull(ItemID) Then
Set db = CurrentDb
ssql = "SELECT * FROM tbl_Data2 WHERE (([PERSONID]) = " & Me.PersonID & " AND ([RECORDID]) < " & Me.RecordID & ") ORDER BY RECORDID DESC"
Set rst = db.OpenRecordset(ssql)
rst.MoveFirst
ItemID = rst.Fields("itemid")
rst.Close
Set db = Nothing
Else
Exit Sub
End If
Which would find the most recent record by recordID and use the value in the ITEMID field to populate the current record. You can determine what gets populated by adjusting the SQL statement so that the record you want always appears first.