Microsoft KB Archive/319320

= ACC2000: &quot;You Cannot Add or Change a Record...&quot; Error Message When You Try to Add a Product to a New Order =

Article ID: 319320

Article Last Modified on 1/7/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q319320



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you try to add a product to a new order in the Orders form in the Order Entry sample database, you may receive an error message similar to the following:

You cannot add or change a record because a related record is required in table 'Orders'.



CAUSE
This behavior occurs if you do not click an item in the Employee combo box before you try to add a product to the Products subform.



RESOLUTION
To resolve this issue, use either of the following methods.

Method 1: Modify the On Enter Event Procedure of the Order Details Subform
To modify the On Enter property of the subform control, follow these steps:  Open the Orders form in Design view. Click the subform control, and then click Properties on the View menu. Click the Event tab, click the On Enter property, and then click the Build button.  Replace the existing event procedure with the following one: Private Sub Order_Details_Subform_Enter On Error GoTo Err_Order_Details_Subform_Enter If IsNull(Me![OrderID]) Then Me![OrderDate] = Date Forms!Orders!OrderID.SetFocus DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,, acMenuVer70 Forms!Orders![Order Details Subform].SetFocus End If

Exit_Order_Details_Subform_Enter: Exit Sub

Err_Order_Details_Subform_Enter: MsgBox Err.Description Resume Exit_Order_Details_Subform_Enter

End Sub  Quit the Visual Basic Editor, and then open the Orders form in Form view.</ol>

Method 2: Click an Item in the Employee Combo Box
Before you try to add a product in the Products Subform, click an item in the Employee combo box.

Additional query words: prb

Keywords: kberrmsg kbprb KB319320

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.