Bookmark fails

  • Thread starter Thread starter Morten Snedker
  • Start date Start date
M

Morten Snedker

Hi folks,

I've tried googling and alot have had problems similar to mine. I've
tried resolving, but just can't get it to work.

A form showing af running list of orders is used to navigate to a
given record on the frmOrdre with this simple code:

Dim frm As Form
Set frm = Forms!frmOrdre

Dim rs As Recordset
Set rs = frm.RecordsetClone

rs.Find "ID=" & Me.ID
frm.Bookmark = rs.Bookmark

rs.Close
DoCmd.Close acForm, Me.Name


On frm.Bookmark = rs.Bookmark it stops with

"Runtime error 2001:
You cancelled the previous operation."

There are NO pending jobs on frmOrdre (he states with selfconfidence)
- Dirty is False. No combos, lists or alike are in edit/changed mode.

rs.EOF and rs.BOF are both false and the rs.Recordcount states +4000
records.

I'm running an Access 2002 ADP against SQL-Server 2000.

Moving the mouse over the frm.Bookmark text gives the pop-up text
"Can't get value of this property" (freely translated from Danish).

The funny thing (ha ha): SOMETIMES it works...but mostly doesn't.

Any ideas?


Regards /Snedker
 
I can't be sure this is the problem, but here is what I see. The Find method
you are using is specific to ADO recordsets. I would suggest you try it
using the FindFirst method.
 
Actually, there's a whole series of things that could go wrong here, e.g.:
a) The Recordset might have been the wrong type.
b) The form might be dirty with a record that cannot be saved.
c) ID might not have a value.
d) The search value might not be found.
e) You do not close the RecordsetClone of a form (since you did not open
it.)

Try something like this:
Dim frm As Form
Dim rs As DAO.Recordset

If IsNull(Me.ID) Then
MsgBox "Enter a value to find."
Else

Set frm = Forms!frmOrdre
If frm.Dirty Then
frm.Dirty = False
End If

Set rs = frm.RecordsetClone
rs.FindFirst "ID = " & Me.ID
If rs.NoMatch Then
MsgBox "not found"
Else
frm.Bookmark = rs.Bookmark
End If
End If

Set rs = Nothing
Set frm = Nothing
DoCmd.Close acForm, Me.Name
 
On Thu, 30 Mar 2006 06:49:02 -0800, Klatuu


Thanks for your input.

But I don't see how that's an error. Access supports the ADO recordset
fine, also in relation to the Bookmark property.

FindFirst is part of DAO, and I see no point in using this reference
when using an Access Data Project.


Regards /Snedker
 
Actually, there's a whole series of things that could go wrong here, e.g.:
a) The Recordset might have been the wrong type.
It is not. It works periodically - but mostly not.

b) The form might be dirty with a record that cannot be saved.
As I stated with confidence: it is not dirty.

c) ID might not have a value.
The ID does indeed hold a valid value.

d) The search value might not be found.
The value is found.

e) You do not close the RecordsetClone of a form (since you did not open
it.)
That's true...old habbit. :-)


Below: I'll give it a go, but it won't be a proper solution.
ADO/bookmark ought to work...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top