Invalid bookmark when entering data in a subform

G

ggregg

I have a mainform for a sales order that has a subform for the sales order
details and a subform for the payment (A customer can pay by more than one
method for a sales order) It all seems very simple but sometimes when the
user has entered the sales order and then enters a new record in the payment
subform, the message "Invalid Bookmark" is displayed. Sometimes the message
is that the "record is locked and is being used by another user." It isn't
consistent. I have done a Compact and Repair many times on the program and
the back-end data. I downloaded a program that does a more thorough repair.
I have recreated my forms, the tables and all the indexes. Nothing has
helped. Any help I information I can find has to do with coding for the
bookmark in the modules. I don't have any. Has anyone had this problem
before or know of anything else I can try? Thanks.
 
A

Allen Browne

A decompile might help. Also make sure Name AutoCorrect is off. Details
below.

There are several other things that could affect this, depending on what
events you are using. Suggestions:

- Temporarily remove anything you have in the form's Timer event.

- Be suspicious of anything in keystroke or mouse move, especially if it
requires moving record.

- Explicitly save before anything that necessitates a save (e.g. moving
record, filtering, sorting, requerying, closing form, ...)

- Don't dirty a form unnecessarily (e.g. don't write to any bound control in
Form_Current or Form_AfterUpdate.)

- Cancel the subform's BeforeInsert event if the main form is at a new
record.

- Remove the zero default value in your foreign keys (in table design), and
consider setting their Required property to Yes (e.g. if there should not be
a payment that isn't tied to a sales order.)

- If you OpenRecordset, be sure to Close, and set your object variables to
Nothing before exiting that routine.

And here is a standard sequence to fix a problem database. Try it in order:

1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
In Access 2007, it's:
Office Button | Access Options | Current Database | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact/Repair
or in Access 2007:
Office Button | Manage | Compact/Repair

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. Open Access (holding down the Shift key if you have any startup code),
and compact again.

5. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

6. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, reference ambiguities are resolved,
and the code syntax is compilable.

If it is still a problem, the next step would be to get Access to rebuild
the database for you. Follow the steps for the first symptom in this
article:
Recovering from Corruption
at:
http://allenbrowne.com/ser-47.html
 
G

ggregg

Thank you very much for all of your suggestions.
The AutoCorrect boxes were checked and I removed them.
The compact and repair, decompile and compile, and importing into a new
database all executed successfully.
But the problem still exists.

I'm using Access 2000.
I have a few buttons on the Sales Order form that the user can use to find
information. It seems that sometimes when they click on these and return to
the SO form, the link is lost between the SO and payment subform. The
current SO is fine but the payment shows #error or "invalid bookmark".

I don't have any Timer or BeforeInsert or Form events.
When an information button is clicked, I do a command to save the SO. Then I
open another form where they choose the information they need (ex a customer
or product), copy the info to the SO and close the info form. At this point
the payment shows #error - sometimes.

I'd appreciate any other ideas - thanks
 
A

Allen Browne

Ggregg, you are suggesting that the link is lost between the main form
(bound to the Sales Order table) and the subform (bound to the Payment
table.)

To investigate if this is so, open the Immediate Window (Ctrl+G) once it
fails, and ask Access if the link is intact. Enter questions such as:
? Forms![Sales Order]![Sales Order ID]
? Forms![Sales Order]![Payment subform].LinkChildFields
Naturally you need to use the actual form, field, and subform names in those
expressions.

If you can't identify what's going wrong, post the code from one of the
command buttons that triggers the error.
 
G

ggregg

I tried your suggestion to open a window and ask questions. Everything would
show the correct answer for awhile, then I would enter the question again and
"invalid bookmark" would show up before the response.

I have entered the command to refresh the Sales Order form after an
information form has been opened and closed. This has helped over the last 2
weeks. The error still happens but not very often and sporatically. I think
the "invalid bookmark" error may be a symptom of something else.

Thank you for all your help


Allen Browne said:
Ggregg, you are suggesting that the link is lost between the main form
(bound to the Sales Order table) and the subform (bound to the Payment
table.)

To investigate if this is so, open the Immediate Window (Ctrl+G) once it
fails, and ask Access if the link is intact. Enter questions such as:
? Forms![Sales Order]![Sales Order ID]
? Forms![Sales Order]![Payment subform].LinkChildFields
Naturally you need to use the actual form, field, and subform names in those
expressions.

If you can't identify what's going wrong, post the code from one of the
command buttons that triggers the error.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

ggregg said:
Thank you very much for all of your suggestions.
The AutoCorrect boxes were checked and I removed them.
The compact and repair, decompile and compile, and importing into a new
database all executed successfully.
But the problem still exists.

I'm using Access 2000.
I have a few buttons on the Sales Order form that the user can use to find
information. It seems that sometimes when they click on these and return
to
the SO form, the link is lost between the SO and payment subform. The
current SO is fine but the payment shows #error or "invalid bookmark".

I don't have any Timer or BeforeInsert or Form events.
When an information button is clicked, I do a command to save the SO. Then
I
open another form where they choose the information they need (ex a
customer
or product), copy the info to the SO and close the info form. At this
point
the payment shows #error - sometimes.

I'd appreciate any other ideas - thanks
 
A

Allen Browne

Yes, your conclusion is a fair assumption that something else is going
wrong.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

ggregg said:
I tried your suggestion to open a window and ask questions. Everything
would
show the correct answer for awhile, then I would enter the question again
and
"invalid bookmark" would show up before the response.

I have entered the command to refresh the Sales Order form after an
information form has been opened and closed. This has helped over the
last 2
weeks. The error still happens but not very often and sporatically. I
think
the "invalid bookmark" error may be a symptom of something else.

Thank you for all your help


Allen Browne said:
Ggregg, you are suggesting that the link is lost between the main form
(bound to the Sales Order table) and the subform (bound to the Payment
table.)

To investigate if this is so, open the Immediate Window (Ctrl+G) once it
fails, and ask Access if the link is intact. Enter questions such as:
? Forms![Sales Order]![Sales Order ID]
? Forms![Sales Order]![Payment subform].LinkChildFields
Naturally you need to use the actual form, field, and subform names in
those
expressions.

If you can't identify what's going wrong, post the code from one of the
command buttons that triggers the error.

ggregg said:
Thank you very much for all of your suggestions.
The AutoCorrect boxes were checked and I removed them.
The compact and repair, decompile and compile, and importing into a new
database all executed successfully.
But the problem still exists.

I'm using Access 2000.
I have a few buttons on the Sales Order form that the user can use to
find
information. It seems that sometimes when they click on these and
return
to
the SO form, the link is lost between the SO and payment subform. The
current SO is fine but the payment shows #error or "invalid bookmark".

I don't have any Timer or BeforeInsert or Form events.
When an information button is clicked, I do a command to save the SO.
Then
I
open another form where they choose the information they need (ex a
customer
or product), copy the info to the SO and close the info form. At this
point
the payment shows #error - sometimes.

I'd appreciate any other ideas - thanks



:

A decompile might help. Also make sure Name AutoCorrect is off.
Details
below.

There are several other things that could affect this, depending on
what
events you are using. Suggestions:

- Temporarily remove anything you have in the form's Timer event.

- Be suspicious of anything in keystroke or mouse move, especially if
it
requires moving record.

- Explicitly save before anything that necessitates a save (e.g.
moving
record, filtering, sorting, requerying, closing form, ...)

- Don't dirty a form unnecessarily (e.g. don't write to any bound
control
in
Form_Current or Form_AfterUpdate.)

- Cancel the subform's BeforeInsert event if the main form is at a new
record.

- Remove the zero default value in your foreign keys (in table
design),
and
consider setting their Required property to Yes (e.g. if there should
not
be
a payment that isn't tied to a sales order.)

- If you OpenRecordset, be sure to Close, and set your object
variables
to
Nothing before exiting that routine.

And here is a standard sequence to fix a problem database. Try it in
order:

1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
In Access 2007, it's:
Office Button | Access Options | Current Database | Name
AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact/Repair
or in Access 2007:
Office Button | Manage | Compact/Repair

3. Close Access. Make a backup copy of the file. Decompile the
database
by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. Open Access (holding down the Shift key if you have any startup
code),
and compact again.

5. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access,
see:
http://allenbrowne.com/ser-38.html

6. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

At this point, you should have a database where the name-autocorrect
errors
are gone, the indexes are repaired, inconsistencies between the text-
and
compiled-versions of the code are fixed, reference ambiguities are
resolved,
and the code syntax is compilable.

If it is still a problem, the next step would be to get Access to
rebuild
the database for you. Follow the steps for the first symptom in this
article:
Recovering from Corruption
at:
http://allenbrowne.com/ser-47.html

I have a mainform for a sales order that has a subform for the sales
order
details and a subform for the payment (A customer can pay by more
than
one
method for a sales order) It all seems very simple but sometimes
when
the
user has entered the sales order and then enters a new record in the
payment
subform, the message "Invalid Bookmark" is displayed. Sometimes the
message
is that the "record is locked and is being used by another user."
It
isn't
consistent. I have done a Compact and Repair many times on the
program
and
the back-end data. I downloaded a program that does a more thorough
repair.
I have recreated my forms, the tables and all the indexes. Nothing
has
helped. Any help I information I can find has to do with coding for
the
bookmark in the modules. I don't have any. Has anyone had this
problem
before or know of anything else I can try? Thanks.
 
G

ggregg

There still are some odd errors that occur sporatically. I have rebuilt the
database by opening a new database and importing all the objects. Everything
imports successfully. Yesterday, several users were using the mde and it
became corrupted. Am I importing the error? Is there another way to rebuild
a database? Aside from rewriting it? (it's almost 8,000 kb)
Thanks
 
A

Allen Browne

I don't know what else to suggest, Ggregg.

There has to be another factor in there, probably associated with the code
behind the buttons that trigger the problem.
 

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

Top