Related Records

marcja

Registered User.
Local time
Today, 15:26
Joined
Jul 12, 2006
Messages
12
I've been using an access d/b for ages, it's one of the template (Orders) databases included with access but modded to suit my own use. copy attached with customer details removed.

Last time I used it it worked fine but yesterday, when I tried entering order information, I get an error saying cant add or change a record because a related record is required in table orders.

Can anyone shed some light on the potential problem? Bear in mind I'm not an advanced user and have very limited knowledge on relationships in access.

Thanks in advance.

Marc
 

Attachments

Last edited:
i just tried and didn't have a problem. perhaps try: Tools>Options>General Tab>Compact On Close. close and reopen the db and see what happens. also add error handling to all of the procedures.
 
Tried that, still not working but thanks for the suggestion.

Perhaps if I explain a little better, I get the error when I try adding a new order to a new record, a record that doesn't already have any orders listed. Amending and adding to existing orders works fine.
 
In the Orders form try editing the Order_Details_Subform_Enter() sub to the following:

Code:
Private Sub Order_Details_Subform_Enter()
On Error GoTo Err_Order_Details_Subform_Enter
    
    If IsNull(Me![OrderID]) Then
        Me![OrderDate] = Date
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
        'NEW:
        Me.Refresh
    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
after the code adds the date (Me![OrderDate] = Date), the record is supposed to be saved (DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70). you get sent back to the subform, but the record is still being edited - the acSaveRecord wasn't saving for reasons i can't explain. (i tried changing the 'save' code to 'DoCmd.RunCommand acCmdSaveRecord' but that didn't help. Me.Refresh seems to work.

does it work for you?
 
Wazz,

Cheers mate. Thanks for all your help. That works a treat.
 

Users who are viewing this thread

Back
Top Bottom