Saving main & sub forms

PaulJK

Registered User.
Local time
Today, 11:23
Joined
Jul 4, 2002
Messages
60
Hello,

I have an Orders form (frmOrders) which has a subform (frmOrderDetails) detailing the individual order items. For example, there is one order which may consist of many items.

The problem I have experienced is that if someone completes frmOrderDetails first and then moves to frmOrders the records are not saved correctly. I know this is because the main form frmOrders has not been saved or had a field completed which would produce an OrderID which can be linked to frmOrderDetails.

Whilst I could say to users they must complete a certain field first, some will forget and I would like to protect against this.

Whilst the tab order will go to a field on frmOrders, is there a way of forcing users to complete this field before they enter frmOrderDetails.

Alternatively, is there a way of coding a command button to initiatve an OrderID.

Or do you have any other suggestionsm

Thank you.
 
First of all, have you not Linked Child/Master fields between the form and the subform?

The othe method - although the first is the correct one - is to use the main form's BeforeUpdate event to check if the field you want has a value and, if not, cancel the event with Cancel = True.
 
Thanks for the reply.

I have linked all field and I do check for mandatory fields on both the main & subforms (BeforeUpdate).

However, I did not check that the OrderID was complete. I have adapted my code as follows but would appreciate some help on how I could refocus onto a field on the main form.

If IsNull(Me.OrderID) Or Me.OrderID= "" Then
MsgBox "You MUST enter the order date before orders can be recorded. This field is mandatory!", vbOKOnly + vbCritical, "Error"
DoCmd.RunCommand acCmdUndo
??? I would like to go to a field "OrderDate" on frmOrders
End
End If

Once any guidance is appreciated
 
Your table relationships are incorrect and or you haven't made order id a required field
 

Users who are viewing this thread

Back
Top Bottom