Hi,
I have a subform that is a continuous form.
I have a command button set up to delete a detail record. When a record is deleted, I would like to bump down the value of a field on the records displayed after the deleted record.
Can I do this by accessing the details on the form in any way, and updating them? Or must I create an SQL processing loop to do so? I coded the SQL for this, in the subform's cmdDelete event, but am not quite sure how to do the recordset, how to execute the SQL (and can that initiate a loop?), how to reference the field I want to change, and set up a loop for my select statement. So I got to wondering whether I can reference the detail lines themselves.
If I am on the right track, the code I have generated so far is: (for simplicity, leaving out some of the dim statements).
I get an error on the purple line, for rst.seqno, saying "Compile Error: method or data member not found".
Any suggestions on the best way to go about doing this?
Thanks,
Lori
I have a subform that is a continuous form.
I have a command button set up to delete a detail record. When a record is deleted, I would like to bump down the value of a field on the records displayed after the deleted record.
Can I do this by accessing the details on the form in any way, and updating them? Or must I create an SQL processing loop to do so? I coded the SQL for this, in the subform's cmdDelete event, but am not quite sure how to do the recordset, how to execute the SQL (and can that initiate a loop?), how to reference the field I want to change, and set up a loop for my select statement. So I got to wondering whether I can reference the detail lines themselves.
If I am on the right track, the code I have generated so far is: (for simplicity, leaving out some of the dim statements).
Code:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
For X = MinSeqNum To MaxSeqNum
strSQL = "SELECT tblRoomItems.SeqNo From tblRoomItems " _
& "WHERE (((tblRoomItems.ItemID)= " & [Forms]![fsubRoomItemDetails].[ItemID] & ")" _
& "AND ((tblRoomItems.SeqNo)= " & X _
& "));"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
[purple] rst.SeqNo = X - 1 [/purple]
rst.Update
Next X
Any suggestions on the best way to go about doing this?
Thanks,
Lori