Results 1 to 2 of 2

Thread: invoice problem

  1. #1
    Join Date
    Dec 2003

    Unanswered: invoice problem

    i have an invoice form just like in the northwind database.
    the problem is the invoice can be saved without the user have to input any products in the subform.
    so when the user input the information in the main form and then saves it, it can be saved.
    i want the invoice can't be saved when there's no products in the subform. you know it's like writing an invoice but there's nothing to buy.
    thanks a lot
    hendra gunadi

  2. #2
    Join Date
    Feb 2004
    I assume you are referring to the Orders form and subform in the Northwind database. One solution is to do a record count in the AfterUpdate event of the form that would determine if there are any rows in the subform that match the OrderID in the main form. If you come up with zero, then you would have to delete the current record since the data in the main form might already be committed.
    The code would be something like:

    If DCount("*",RecordSourceOfSubform,"OrderID = " & Me!OrderID) = 0 Then
    DoCmd.RunCommand acCmdDeleteRecord
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts