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?
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?