Results 1 to 6 of 6
  1. #1
    skg is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2011
    Posts
    7

    Ensuring Proper Data Entry

    I have a purchase order form with a subform for line item details. I want to put a Total field on the form that must equal the total of the line item details.

    I want an error message to pop up if the amounts are not equal and keep the information from saving unless they are equal.



    Any ideas where to start?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is this just a double check? You would catch this issue in the BeforeUpdate event of the MainForm. Does that help?

  3. #3
    skg is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2011
    Posts
    7
    Yes it is a double check, but I am not sure of how to write the code.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You would put a TextBox in the Footer of the SubForm (which does not display when the form is in Continuous Form mode) that sums the field you want. Then compare this control with the one on the mainForm in the BeforeUpdate event of the MainForm.

  5. #5
    skg is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2011
    Posts
    7
    Please pardon my ignorance. All of what you have said makes sense, but I still don't understand what code to put in the BeforeUpdate event.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Something like:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
       If Me.MainFormControlName <> Me.SubFormControlName.Form.SummingControlName Then
          MsgBox "Does not balance - NOT saving!", vbCritical + vbOKOnly
          Cancel = True
       End If
    End Sub
    ...using your ControlNames of course!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Proper way to store Names
    By trb5016 in forum Database Design
    Replies: 5
    Last Post: 08-22-2010, 10:16 AM
  2. Sub Form Data Entry
    By OldBloke in forum Forms
    Replies: 1
    Last Post: 08-09-2010, 06:58 AM
  3. Ensuring Everything Works...?
    By catat in forum Access
    Replies: 1
    Last Post: 03-31-2010, 01:44 PM
  4. data entry
    By ngeng4 in forum Forms
    Replies: 22
    Last Post: 03-18-2010, 07:12 PM
  5. Data Entry And Data Recalling
    By GeeDee in forum Access
    Replies: 0
    Last Post: 05-01-2007, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums