selected

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I've got form with master slave subforms. After refresh (so some fields get
their current values) selected rows are changed ( first rows in both subforms
become selected). I dont want that to happen, I want old rows to remain
selected. How can I avoid selection change?
thanx

alek_mil
 
alekm said:
I've got form with master slave subforms. After refresh (so some fields get
their current values) selected rows are changed ( first rows in both subforms
become selected). I dont want that to happen, I want old rows to remain
selected. How can I avoid selection change?


From your explanation, I think you should try using Refresh
instead of Requery. The difference is that Requery
completely reloads the forms data including any new/deleted
records while Refresh only checks for modified data in
existing records.

If that's not sufficient for your needs, you will have to
save the PK field of each subform's current record before
executing the Requery. Then, after the Requery, use the
subform's RecordsetClone to relocate the record with the
saved PK. Assuming the PK fields are all long integers (or
Autonumbers), the code for each subform would be like:

lngPK = Me.subform.Form.pkfield
Me.subform.Form.Requery
With Me.subform.Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "pkfield = " & lngPK
If Not .NoMatch Then
Me.subform.Form.Bookmark = .Bookmark
End If
End If
End With
 
Back
Top