Results 1 to 5 of 5
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Unanswered: Compare Total from Main and SubForm

    I am trying to compare a total on the main form against the total on a sub form.

    When clicking on a command button I need to run a IF statement that

    If The Sum Total of the Main Form = The Sum Total of the Sub Form Then
    Call Function xxx
    Else Msgbox “Out of Balance”.


    Thanks,
    HelpMePlease

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Assuming the following

    Main form total is in control txtTotal
    Subform total is in control named txtSubTotal
    Subform contol is named MySubForm
    and the button is on the main form

    then this, or similar, should do it?
    Code:
    cmdButton_Click()
        IF txtTotal = MySubForm.Form.txtSubTotal then
            Call sub/function
        Else
            MsgBox “Out of Balance”.
        End If
    End Sub
    MTB

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    cmdButton_Click()
    dim x,y,z


    IF txtTotal = MySubForm.Form.txtSubTotal then
    Call sub/function
    Else
    x = txtTotal
    y = MySubForm.Form.txtSubTotal
    z = x - y
    MsgBox “Out of Balance - the difference is..." & ccurr(y)
    'Note that the period in the previous example was OUTSIDE the
    'the quotes - needs to be in the quotes - other than that
    ' all I did was expand the message to give the difference
    End If
    End Sub
    Dale Houston, TX

  4. #4
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    I have tried this and I still get a error. I have attached a copy of the error.
    Attached Files Attached Files

  5. #5
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    Sorry, Ignore my last message. I have just spotted what I was doing.

    Think I might have to change my name to "plonker"

    Thanks anyhow

Posting Permissions

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