|
|
Stay on the same record
In a form, I have many records, with a scroller.
When I make a modification on one, I have this code
Me.Requery
to see the effect of my modification. But with that command, my pointer is
back to
the top of my list .
Any suggestion to stay on the same record I have modified, after the
modification?
Best regards
|
|
0
|
|
|
|
Reply
|
Pierre
|
3/10/2007 5:36:40 PM |
|
You could also try the following:
Dim r as Long
r = Me.CurrentRecord
Me.Requery
DoCmd.GoToRecord , , acGoTo, r
"Ofer Cohen" <OferCohen@discussions.microsoft.com> píše v diskusním
příspěvku news:D69A1729-D63E-4B19-941F-2B7A51CF8663@microsoft.com...
> Check help on Access BookMark
>
> --
> Good Luck
> BS"D
>
>
> "Pierre-Yves Ste-Marie" wrote:
>
>> In a form, I have many records, with a scroller.
>> When I make a modification on one, I have this code
>> Me.Requery
>> to see the effect of my modification. But with that command, my pointer
>> is
>> back to
>> the top of my list .
>> Any suggestion to stay on the same record I have modified, after the
>> modification?
>>
>> Best regards
>>
>>
>>
>>
|
|
0
|
|
|
|
Reply
|
Utf
|
3/11/2007 8:18:41 AM
|
|
In news:ezpFgX7YHHA.688@TK2MSFTNGP03.phx.gbl,
Vladim�r Cvajniga <nospam@thank.you> wrote:
> You could also try the following:
>
> Dim r as Long
> r = Me.CurrentRecord
> Me.Requery
> DoCmd.GoToRecord , , acGoTo, r
That won't work if some other user has added or deleted records from the
recordsource since it was originally queried.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
|
|
0
|
|
|
|
Reply
|
Dirk
|
3/11/2007 7:20:33 PM
|
|
In news:P1CIh.119415$1h1.856446@wagner.videotron.net,
Pierre-Yves Ste-Marie <stemariepy@videotron.ca> wrote:
> In a form, I have many records, with a scroller.
> When I make a modification on one, I have this code
> Me.Requery
> to see the effect of my modification.
Do you really need to do this? Would Refresh and maybe Recalc do as
well?
> But with that command, my pointer is back to
> the top of my list .
> Any suggestion to stay on the same record I have modified, after the
> modification?
The safest method, if you must requery, is to save the primary key of
the current record before you requery, then relocate to that key
afterward. Here's a basic outline of the code:
Dim vID As Variant
' Save the current record's primary key.
vID = Me.ID ' where ID is the primary key field
Me.Requery
Me.Recordset.FindFirst "ID=" & vID
If the primary key is a text field, you'll need to enclose it in quotes
for the FindFirst criterion:
Me.Recordset.FindFirst "ID=" & Chr(34) & vID Chr(34)
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
|
|
0
|
|
|
|
Reply
|
Dirk
|
3/11/2007 7:24:33 PM
|
|
|
3 Replies
410 Views
(page loaded in 0.192 seconds)
|
|
|
|
|
|
|
|
|