Goto Record

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

Guest

Hi,
I have a form that displays data from different records. I added a buttton
to remove the filter when I do not want it anymore. The simple code is:
strFiltre = "([NO_DOSS_IR] = ""*"")"
DoCmd.ApplyFilter FilterName:=strFiltre
When this code executes, the first record is displayed.
I would like to redisplay the record that was displayed when the button was
clicked.
Is that possible?
I thought I could take note of the value of the primary key (NO_DOSS_IR) and
then use the DoCmd.GoToRecord but I can't find the right syntax.
Do I need to create a Recordset and use a bookmark? If yes, then how do I
get to display the right record without filtering the data?
Thanks.
 
Hi,
yes, you have to same the value of selected record ID in some variable, then
you can select this record back - first remove filter, then:

me.recordsetclone.findfirst "[NO_DOSS_IR] = " & lngSavedID
if not me.recordsetclone.nomatch then
me.bookmark=me.recordsetclone.bookmark
end if
 
Hi Alex,
That is the answer. It works fine now.
That gave me a chance to check the help file on the RecordsetClone and
Bookmark items.
Thank you very much and have a good day.
--
Jac Tremblay


Alex Dybenko said:
Hi,
yes, you have to same the value of selected record ID in some variable, then
you can select this record back - first remove filter, then:

me.recordsetclone.findfirst "[NO_DOSS_IR] = " & lngSavedID
if not me.recordsetclone.nomatch then
me.bookmark=me.recordsetclone.bookmark
end if

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Jac Tremblay said:
Hi,
I have a form that displays data from different records. I added a buttton
to remove the filter when I do not want it anymore. The simple code is:
strFiltre = "([NO_DOSS_IR] = ""*"")"
DoCmd.ApplyFilter FilterName:=strFiltre
When this code executes, the first record is displayed.
I would like to redisplay the record that was displayed when the button
was
clicked.
Is that possible?
I thought I could take note of the value of the primary key (NO_DOSS_IR)
and
then use the DoCmd.GoToRecord but I can't find the right syntax.
Do I need to create a Recordset and use a bookmark? If yes, then how do I
get to display the right record without filtering the data?
Thanks.
 
Back
Top