I have a form, frmCustomer, that has a subform, sfrmFileTypes. My problem is that when I'm entering a new customer and the CustomerID is still blank, I don't want the subform to have any data put into it because it then gets assigned to the customer with the blank CustomerID. I know that if I just fill out the main form first and then go to the subform, everything will work fine. I just want to block it so that it is impossible to update the subform without the CustomerID field being populated.
Here are the relevent fields in the tables behind the two forms:
tblCustomer
CustomerID
CustomerName
tblFileTypes
FileTypeID
CustomerID
FileName
The control names on the forms are the same as the field names FYI.
I just want to know the best way to do this as I'm sure that there are a few options. I could probably do something like the following in the before update event on the subform:
- If IsNull(Me.CustomerID) Then
-
Me.Form.AllowEdits = False
-
End If
Although, I don't think that there is a before update event for subforms. I really don't want to write code similar to the above for every control in the subform.