Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-08-2007, 09:55 AM
Ecron's Avatar
Ecron Ecron is offline
Registered User
 
Join Date: Aug 2006
Location: Harrisonburg, VA, USA
Posts: 58
Ecron is on a distinguished road
bookmarking problem with recordsetclone

I have been trouble with a function that i coded to requery a subform and keeping the same record position.

My function is as follows:
Code:
Public Function Search_AND_Requery(search As String, frm As subform, nPK As Integer)
    frm.Requery
    
    With frm.Form.RecordsetClone
        .FindFirst search & " = " & nPK
        If Not .NoMatch Then
            frm.Form.bookmark = frm.Form.RecordsetClone.bookmark
        End If
    End With
    
End Function
Now. on the line where it says "frm.Form.bookmark = frm.Form.RecordsetClone.bookmark" it generates the error 2001 which is the canceled previous operation error.

If i hit debug and then just resume the code it works.

Also, something interesting i figured out is that if i put just a blank messagebox before setting the bookmark then everything works out.

Any ideas or help would be lovely!

Thanks
Reply With Quote
Sponsored Links
  #2  
Old 05-08-2007, 03:29 PM
lagbolt's Avatar
lagbolt lagbolt is offline
AWF VIP
 
Join Date: Mar 2004
Location: Vancouver BC
Posts: 1,657
lagbolt has a spectacular aura aboutlagbolt has a spectacular aura about
Your code actually creates two clones. One is created at your With block.
Your problem line does not reference the same clone against which you've run your find operation. Your problem line creates a whole new clone.
Try...
Code:
With frm.Form.RecordsetClone
  .FindFirst search & " = " & nPK
  If Not .NoMatch Then frm.Form.bookmark = .bookmark
End With
I avoid the bookmark issue altogether as follows...
Code:
With frm.Form.Recordset
  .FindFirst search & " = " & nPK
  If .NoMatch Then MsgBox "Not Found"
End With
Reply With Quote
  #3  
Old 05-09-2007, 06:19 AM
Ecron's Avatar
Ecron Ecron is offline
Registered User
 
Join Date: Aug 2006
Location: Harrisonburg, VA, USA
Posts: 58
Ecron is on a distinguished road
Hello.

Firstly, I would like to thank you very much for your aide and advice. I notice now that there are two recordsetclones and was completely unaware of that.

After editing the code to match your first example, the problem still arose and instead of highlighting the entire line it just highlighted beginning with frm.Form.bookmark and to the end. I'm assuming it has to do with my frm variable because it is rather... ambiguous, in a way.

Then, I went to try the second example.

Now, the way that I have the form set up. There are some text boxes and whatnot and then a continuous subform with a bunch of entries within it. What I was setting up was a way for the user to just click on of these continuous subform entries and it would automatically select that entry to it's parent form.

The problem with the second example is that the record is not selected, meaning the record indicator along the left hand side is not pointing towards that record... but the record is highlighted without actually being selected. Quite annoying.

In conclusion, I have decided to change a few things and do some combo boxes instead of the continuous subform as it will be much easier and take less work and I won't have to worry about recordsets at all!

Thanks again!
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
conversion problem marc01 General 1 01-01-2007 03:58 AM
Saving Problem mohammadagul Forms 2 04-25-2004 10:01 AM
Problem with Saveing Record mohammadagul Modules & VBA 3 04-25-2004 09:58 AM
(Simple) problem with RecordsetClone. RHT General 2 03-26-2004 02:46 PM
Math Problem.. mission2java_78 General 3 08-28-2002 11:24 AM


All times are GMT -8. The time now is 07:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World