Jet database engine cannot find a record

  • Thread starter Thread starter Amir
  • Start date Start date
A

Amir

Hi!

I have a form of receipts with many fields:
ReceiptNumber, ProductKeyInReceipt etc.

When I am pressing the "New Record" button, I get the
following message: "The Microsoft Jet database engine
cannot find a record in the table 'tblProducts' with key matching
field(s) 'ProductKeyInReceipt'". What does that mean?

There is a subform in this form, which should show exctaly
what's the form's showing, but in continuous view.
Does that have any connection to the error message?

I have checked and the error is showing due to the
Msgbox Err.Description line, but I don't know why..

I would be thankful if you could help!

Here is the code:

Private Sub btnAddNewReceiptEvent_Click()
On Error GoTo Err_btnAddNewReceiptEvent_Click
DoCmd.GoToRecord , , acNewRec

'These lines are to synchronize the data in the form with the receipt
number data, which I save in ReceiptNumber textbox.
If Not IsNull(Me.OpenArgs) Then
Me!ReceiptNumber.SetFocus
Me!ReceiptNumber.Text = Me.OpenArgs
Me!ProjectName.SetFocus
Me.Requery
End If
'End of synchronization lines.

Exit_btnAddNewReceiptEvent_Click:
Exit Sub

Err_btnAddNewReceiptEvent_Click:
MsgBox Err.Description
'The error message appears here.
Resume Exit_btnAddNewReceiptEvent_Click

End Sub
 
There is a value in the form that is preventing Access from saving the
record. My guess is that this value derives from the Default Value for the
foreign key field.

Open your table in design view.
Select the foreign key field.
In the lower pane, remove the zero beside Default Value.
 
Depends what is causing the error message.

If it is something like "The value is not appropriate ...", use the Error
event of the form.
 
OK, thank you very much!

Now I get the same error message only when I am editing
a new record and trying to press with the mouse on the subform,
before I've ended editing the new record.

How can I cancel the error message that is showing,
and replace it with other message?

Amir.
 
Back
Top