Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Not a Valid Bookmark" - Mystery

Status
Not open for further replies.

HenriM

Programmer
Sep 9, 2002
56
GB
I am using Access 2002 in Office XP on Windows98.

In one project I have several forms which require a Recalc when certain data is input or changed, and the focus must go back to the right object in the right record.

To do this, thanks to "tek-tips" I have the following code:-

Dim BM as Variant
If Me.Dirty Then
BM = Me.Bookmark
Me.Recalc
Me.Bookmark = BM
End If
Me.[objectname].SetFocus

This works perfectly on every Form except one and, except for content, there is no structural difference between any of them.

With this one form I get a "Not a Valid Bookmark" error and on Debug the line "Me.Bookmark = BM" is highlighted.

In the Debug Window the Command ?BM produces the correct result,"?".

Select "End" and the bookmark is skipped and the focus goes to the first object in the first record. Recalc is of course carried out.

This happens with the first object selected the first time the form is opened. It doesn't matter which of four object I select first, the error occurs.

Moving the focus to another object requiring Recalc and making a change, the code works correctly. Also, if I click to another form and them back again the code works.

Now for a final puzzle; if I open the form in Database Manager it defaults to the first record as one would expect. BUT !!!! Editing any of the objects, the Recalc works and the Bookmark is recognised.

So to recap, the error only appears the first time a change is made and when the form is opened from within the project itself.

It does not happen with any of the other Forms in the project - yet these work in exactly the same way, just using different tables or queries.

The only answer seems to be to delete the offending form and re-create it from scratch - but has anyone else experienced this and found out how and why it happens?
 
Having had no response to this (most unusual!!) but having traced the problem myself I thought the cause and solution might be of use to other members.

Basically what I was doing wrong was to have a subform duplicated on the main Form, with different master/child links. (One linked to Self and one to Partner). This worked fine until I introduced the Bookmark routine, causng a conflict. Logic says it should not have done, but it did!

Also, I had another Form - for Single people - where the same subform was used. This gave me the same problem


So I deleted the second subform; made a copy under a different name and linked this to Partner. I then made a third copy and used this on my Singles Form.
This had the effect of creating duplicate code and a new Bookmark reference - so no conflict!

Moral - although Acess will quite happily allow you to use the same subform twice or more in the same project, and link to different RecordSets, this problem (and perhaps others) will occur and it is better not to do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top