Results 1 to 7 of 7
  1. #1
    spkoest is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    16

    VBA problem with IF comparison. HELP.


    removed to sumarize
    Last edited by spkoest; 05-03-2011 at 04:17 PM.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    this is extremely long, and you've post 3 times. that is really deterring.

    can you shorten it to explain the issue in a few short steps? I, for one, am not reading all of this...

    (only reason I care to help is because interest/money problems are interesting to me)

  3. #3
    spkoest is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    16
    To summarize even more:

    My question is this:

    When walking through debug on the code below what circumstances could exist that when hovering over the bolded values InterestAmount and RoundedInterest they both show a value of 147.99 but the conditions is not true and interestWarning. Visible is not set to False.

    Controls for the two amounts are as follows:
    InterestAmount =[Forms]![frm interest pick]![interest]
    RoundedInterest =Sum([percent])


    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    If InterestAmount = RoundedInterest Then
    InterestWarning.Visible = False
    Else
    InterestWarning.Visible = True
    End If

    End Sub

  4. #4
    spkoest is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    16
    My guess is it has something to do with Sum(percent) of control source on the RoundedInterest field. The Control has a format of Currency with 2 decimal points. So would it display the textbox in this format in debug but compare to a different decimal level?

  5. #5
    spkoest is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    16
    Or it has something to do with it being in the On Format event of the report footer. I moved the code to the On Print Event of the report footer and the same results occured.

  6. #6
    spkoest is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    16
    Reports: Show totals at bottom of report
    Author(s)Dev Ashish(Q) I want to show a total at the bottom of each page, but I keep seeing #error instead, whats wrong?
    (A) Your problem is that access does not allow the Sum() function in the page footer. So to get around the problem, create a control in another section of your report that performs the calculation, and set its visible property to false. Then create another unbound text box in the page footer. Enter the name of the control containing the calculation as the text boxes controlSource property setting.

    I wonder if the SUM() is not allowed in the report footer? Hmmmm. but debug shows it????????

  7. #7
    spkoest is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2009
    Posts
    16
    Well... I created to variables, assigned the control.values to those variables, then compared the variables in my If statement and it works.

    Still not sure what is going on but it is a work around.

    Thanks for letting me ramble.


    Dim varInterestAmount As Currency
    Dim varRoundedInterest As Currency


    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    varInterestAmount = InterestAmount
    varRoundedInterest = RoundedInterest
    If varInterestAmount = varRoundedInterest Then
    InterestWarning.Visible = False
    Else
    InterestWarning.Visible = True
    End If


    End Sub

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

Similar Threads

  1. Short date comparison
    By andy101 in forum Programming
    Replies: 2
    Last Post: 03-17-2011, 04:36 AM
  2. Comparison Feature Help
    By Kapelluschsa in forum Access
    Replies: 2
    Last Post: 10-25-2010, 06:43 AM
  3. Boolean Comparison Not Working
    By Rawb in forum Programming
    Replies: 4
    Last Post: 09-03-2010, 09:17 AM
  4. Comparison
    By VICTOR HUGO in forum Access
    Replies: 8
    Last Post: 02-10-2010, 04:32 PM
  5. Time Comparison
    By Larry819 in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 09:26 PM

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