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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access; "Find Record" button produces "Not A Valid Bookmark" message.

Status
Not open for further replies.

jeffmorl

Programmer
Mar 30, 2011
33
US
I have a single form that users have been using for months and months. All of a sudden, when someone does a search for a particular record ID, it fails and produces a Not A Valid Bookmark message that won't go away. The user then has to red 'x' out of the application.

Using MS Office 10, Access version 14.0.6xxxx. Application written in Access 2003 (I think).
 
jeffmorl,

Can you go ahead and post the code behind the button for now... or is it run with a Macro, currently? If code, go ahead and post here, just to be sure looking at the same thing. I know in Access 2010, if I use a wizard to create any button function, it now creates an Access Macro instead of a VBA script.


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Sure. It's just a standard "Find" button. Here is the code behind the button.

Code:
Private Sub Command72_Click()
On Error GoTo Err_Command72_Click
' search button

    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdFind

Exit_Command72_Click:
    Exit Sub

Err_Command72_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_Command72_Click
    
End Sub
 
I'm amazed the post went through - it was timing out on my end..

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Hmm, I'm guessing that the user input an invalid ID value, whatever that may be?

So you could either use a different search method, or with the current one, add some error handling - that's my initial thought...

so...
Code:
Private Sub Command72_Click()
On Error GoTo Err_Command72_Click
' search button

    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdFind

Exit_Command72_Click:
    Exit Sub

Err_Command72_Click:
    Select Case Err.Number
        Case 3159 'Change this to the actual number that is given with this error, if this is not correct.
            Msgbox "Your search entry is invalid, please try again.",vbInformation,"Invalid Search"
        Case 'Any others you want to handle, put the Err Number here.
            Msgbox "An error has occurred, please contact the admin with the following inforation:" & vbCrLf & vbCrLf & _
                   "Error Number = " & Err.Number & vbCrLf & _
                   "Description = " & Err.Description
        Case Else
    End Select

    Resume Exit_Command72_Click
    
End Sub

At least that may be a start... If you're certain the value IS accurate, correct, no spaces, no funny characters, etc, then you may want to try checking for corruption would be my next guess.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Right... I've been testing this for a few days and know for certain that the recordID is correct; it's an autonumber generated by Access when the record is created.

How does one go about checking for corruption? A Compact and Repair doesn't prevent the problem.
 
Only way I know of to fix it for certain is to create a new database and import everything into it... If you know it's the table, then I'd export the data to a text file to be safe, then import into a newly created table.

Another thing you could try is to run a Decompile on the database - not just compact and repair. Though, for a table corruption, I'd be shocked if it helped.

Here's are reference on how to decompile:

It's about 2/3 the way down the page. That page actually has lots of info, lots of ways to work with corrupted databases.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top