search query was not found for any record

DevAccess

Registered User.
Local time
Today, 05:10
Joined
Jun 27, 2016
Messages
321
Hello

I am creating and saving record and when it asks for confirmation and select no save record, it gives me below error..

search query was not found for any record.

Code:
 If MsgBox("Do you want to save the changes?", vbYesNo) = vbNo Then
    Me.Undo
    Cancel = True
else
 .......
end if

Thanks
 
sounds like corruption

inspect the table, and see if there are any records with "Chinese" characters. It's always a good indicator

you might be able to edit no records, or some records. the corrupt records won't be editable. It's a bit of a "needle in a haystack" job, though.
 
It would probably help if you were to post the entire code, including the Sub Header, so we know where you're trying to execute this code.

Also, 'search query was not found for any record' has no apparent relationship to the task at hand...saving or not saving a Record. Error messages, in Access, not actually being germane to the error that is occurring is nothing new, but something is obviously causing it. In the above code, the line

Cancel = True

for instance, will cause an error if used in the OnClick event of a Command Button, because those events appear like this

Private Sub cmdButtonName_Click()

not

Private Sub cmdButtonName_Click(Cancel As Integer)

because a Command Button OnClick Property doesn't include Cancel.

Linq ;0)>
 
It would probably help if you were to post the entire code, including the Sub Header, so we know where you're trying to execute this code.

Also, 'search query was not found for any record' has no apparent relationship to the task at hand...saving or not saving a Record. Error messages, in Access, not actually being germane to the error that is occurring is nothing new, but something is obviously causing it. In the above code, the line

Cancel = True

for instance, will cause an error if used in the OnClick event of a Command Button, because those events appear like this

Private Sub cmdButtonName_Click()

not

Private Sub cmdButtonName_Click(Cancel As Integer)

because a Command Button OnClick Property doesn't include Cancel.

Linq ;0)>

if we dont put any code in form before update event it works but if we want to confirm whether user want to save the record or not.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo errorhandler
 If MsgBox("Do you want to save the changes?", vbYesNo) = vbNo Then
    Me.Undo
    Cancel = True

  '  Exit Sub
Else
End If
exit sub
error handler:
  msgbox error.description
exit sub
end sub

the error " the search key not found for any record" is giving only when user cancels the saving..
 
if we dont put any code in form before update event it works but if we want to confirm whether user want to save the record or not.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo errorhandler
 If MsgBox("Do you want to save the changes?", vbYesNo) = vbNo Then
    Me.Undo
    Cancel = True

  '  Exit Sub
Else
End If
exit sub
error handler:
  msgbox error.description
exit sub
end sub

the error " the search key not found for any record" is giving only when user cancels the saving..

If I remove me.undo it is working , dont know what is wrong.
 

Users who are viewing this thread

Back
Top Bottom