Re: Removing filter loses bookmark
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Sat, 8 Apr 2006 00:07:20 +0800
Yes, you will find yourself back at the first record if you set or remove a
filter, change the sorting, change the RecordSource, or requery the form.
There is no need to use the Timer though, and there is still no need to use
the Current event. After you do any of the above, you can FindFirst the
previous primary key value again in the RecordsetClone of the form.
Assuming a numeric primary key named ID, the code will go something like
this:
Dim varValue As Variant
If Me.Dirty Then Me.Dirty = False 'save first.
varValue = Me.ID 'Save the primary key value.
Me.RecordSource = "SELECT FROM Table1;"
If IsNull(varValue) Then 'Must have been a new record
If Not Me.NewRecord Then
RunCommand acCmdRecordsGotoNew
End If
Else
With Me.RecordsetClone
.FindFirst "ID = " & varValue
If .NoMatch Then
MsgBox "That's not in Table1."
Else
Me.Bookmark = .Bookmark
End If
End With
End If
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Kate" <eppstein@xxxxxxxxx> wrote in message
news:ut11dolWGHA.1348@xxxxxxxxxxxxxxxxxxxxxxx
Allen, thank you for replying. Your advice is always good.
The difficulty of this situation is that I have the form's recordsource
dynamic (set only in code), because
depending upon which types of records are selected as the basis, a
different table might form the source. Whenever I change the sort order
of the recordset, I reset the recordsource of the form AND
the rowsource of a combobox that allows one to choose an individual
record.
Isn't it a default of Access that when a filter is removed, and all
records are shown, the first record becomes the default?
I have managed a work-around by setting the timerinterval to 1000 when the
filter is removed,
before I reset the form's recordsource, and then in the ontimer event, I
go back to the correct id
and the current event doesn't fire. However, this might not work on a
slower computer!!
-Kate
Allen Browne wrote:
Whatever you have in the Current event has to be removed.
If you have any code or macro that requeries the form or applies/removes
a filter so that the form returns the the first record, you have a
circular logic problem and you must remove that code.
.
- Follow-Ups:
- Re: Removing filter loses bookmark
- From: Kate
- Re: Removing filter loses bookmark
- References:
- Removing filter loses bookmark
- From: Kate
- Re: Removing filter loses bookmark
- From: Allen Browne
- Re: Removing filter loses bookmark
- From: Kate
- Removing filter loses bookmark
- Prev by Date: Re: Requerying subforms
- Next by Date: Re: Close Btn Confirmation
- Previous by thread: Re: Removing filter loses bookmark
- Next by thread: Re: Removing filter loses bookmark
- Index(es):
Relevant Pages
|
|