Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't add new record in subform

Status
Not open for further replies.

rockfish12

Technical User
Feb 12, 2002
31
US
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?
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?
 
Never mind, I figured it out. I modified one of the command buttons on the main Orders form to set the AllowAdditions subform property to True.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top