rockfish12
Technical User
I have a form (Orders) that has a subform (Order Details), both of which have queries as their record sources. In the course of trying to make sure that users don't accidentally add, edit, or delete an Order Detail record, I added some code to the On Current event of the Order Details subform that only allows edits when the Orders form is editable. The code works great, except for when I come to an order that has no order details - such as when entering a brand new Order record. Unless one is editing a preexisting Order record with associated Order Details records, no new Order Details record can be added.
Code appears below. What am I missing?
How can I allow record additions to the subform even in cases where it has no previous records, given the constraint that I don't want to allow additions by default?
Code appears below. What am I missing?
Code:
Private Sub Form_Current()
If IsLoaded("frmOrders") = True Then
If Forms!frmOrders.AllowEdits = False Then
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
End If
End Sub
How can I allow record additions to the subform even in cases where it has no previous records, given the constraint that I don't want to allow additions by default?