Move to specific record after form requery

  • Thread starter Thread starter jnew
  • Start date Start date
J

jnew

Greetings (again)!

I am trying to create a form with a "delete" button that
doesn't actually delete the current record, but instead
sets a hidden "delete" checkbox to true. The form's
recordset queries out "deleted" items. The button
currently sets the "delete" value to true and requeries
the form.

Requerying the form, however, always returns the form to
the first record. I'd like it to display the "next" record
in the set (or the previous record if the deleted record
was EOF).

Any help with the code will be greatly appreciated.

jn
 
This example:
- Undoes the entry if it is a new record.
- Marks the record as "Delete", and saves the change.
- Gets the primary key value of the record being hidden.
- Requeries.
- Finds the next record, or the last one if there are no more.

Private Sub cmdDelete_Click()
Dim strWhere As String

If Me.NewRecord Then
If Me.Dirty Then
Me.Undo
Else
Beep
End If
Else
Me.[DeletedCheckboxNameHere] = True
Me.Dirty = False
strWhere = "[ID] > " & Me.[ID]
Me.Requery
With Me.RecordsetClone
.FindFirst strWhere
If .NoMatch Then
.MoveLast
End If
Me.Bookmark = .Bookmark
End With
End If
End Sub
 
Back
Top