Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2004
    Posts
    173

    Unanswered: sbuform / form validation

    I'm wondering if there is a better way to do this. I've got a form where invoice information is entered. A given invoice can be coded to several accounts, so a subform allows the individual line entries. What I need to do is validate that the total on the outside form is the same as the sum of the lines in the subform when you navigate away from the form's record. The forms before update event will fire when you first enter the subform so that won't work. What I did was put in custom nav buttons on the form, and capture the keys that would allow navigation to a new record. This works but it is kind of slow. Has anyone done something like this. If so how? I should mention I have no record exit event; I'm using Access 2k. TIA

  2. #2
    Join Date
    Apr 2004
    Posts
    173
    Anyone?? Anyone??

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    What???? What is it you're doing? I couldn't follow what you're asking for ...
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    You can check the invoice total on the main form from the sub-form. In the sub-forms Form Update event (which is fired every time the sub-form is updated) you can use code along these lines:

    If Parent.txtInvoiceTotal <> Dsum(InvoiceSubTotal, "InvoiceDetail Table","Invoice Number = 10") Then Msgbox "The Invoice total must equal the invoice sub-total"

    The Parent property refers to the main forms properties from the sub form. If you open the sub form as a form you will get an error message.

    I hope this helps
    Justin

  5. #5
    Join Date
    Apr 2004
    Posts
    173
    Along those lines wouldn't the message that the sum of the lines don't equal the total fire every time a line was added until the sum equalled the total. The subform is displayed as continuous forms.

    This does give me an idea though. I think I'll try cancelling the exit event of the subform till the total matches. Thanks.

  6. #6
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    Another way would be to run a validation routine when the user finishes an invoice to check that the totals match. You could place the routine on a button that the user has to press when they want to go to a new invoice. The code validates the current invoice and stops them from moving on.

  7. #7
    Join Date
    Apr 2004
    Posts
    173
    That's a little like what I have now, but it's lots of overhead for such a little thing. There are so many ways to leave the current record between the nav buttons and the keyboard. I guess I could hide the nav buttons and cancel and keys, I might try this if my other does pan out. Thanks.

Posting Permissions

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