Bookmark (1 Viewer)

kirkm

Registered User.
Local time
Today, 16:01
Joined
Oct 30, 2008
Messages
1,257
I'm a bit confused about Bookmark.
I have the following code
Code:
 Set rtable = Form_Mysubform.Form.RecordsetClone
   rtable.FindFirst "Prefix = '" & Prefix & "'"
   If Not rtable.NoMatch Then
        Form_Mysubform.Form.Bookmark = rtable.Bookmark
        
        Do
        ...
        rtable.MoveNext
        Loop Until rtable!Year <> lstYear
   End If
I wish to show the progress through DOLoop by Bookmark, just to see what is happening. In the above this won't happen as bookmark is outside the loop. Do I need Findfirst, No Match each time? Obviously it will have found the next record with MoveNext. Is there another to show progress down the Form?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:01
Joined
Oct 29, 2018
Messages
21,467
Hi. Have you tried using the bookmark inside the loop?
Code:
Do...
...
rtable.MoveNext
Me.Bookmark = rtable.Bookmark
Loop...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:01
Joined
May 7, 2009
Messages
19,233
Code:
Set rtable = Form_Mysubform.Form.RecordsetClone
rtable.FindFirst "Prefix = '" & Prefix & "'"
If Not rtable.NoMatch Then
        
        While rtTable![Year] = lstYear
	        Form_Mysubform.Form.Bookmark = rtable.Bookmark
        	...
        	rtable.MoveNext
	Wend
End If
 

kirkm

Registered User.
Local time
Today, 16:01
Joined
Oct 30, 2008
Messages
1,257
Many thanks for the relies. Yes, I could see it should be in the Loop but wasn't sure if Find and Match were also needed. But I see now and have changed to arnelgp method. I haven't used While-Wend and don't think you can early exit from it ?
Can I also ask... in my While Wend I Set a new recordset directly on the table and pass it to a function as Recordset. This is the same source as the RecordsetClone, so I think it's not correct (even though it works). Only certain fields as needed, not all. Is there is a better or proper way to do this ?
 

Users who are viewing this thread

Top Bottom