0

All,

Have a frustrating report problem. Have code of:

Function RAmount()
    HrsAmt = DLookup("trp_ham", "qryTIMshtS", "[trp_id]=" & Me![Row_ID])
    MilAmt = DLookup("trp_mam", "qryTIMshtS", "[trp_id]=" & Me![Row_ID])
    RAmount = HrsAmt + MilAmt
End Function
Function RCount()
    RCount = DCount("trp_id", "qryTIMshtS")
End Function
Function RTotal()
    HrsTot = DSum("trp_ham", "qryTIMshtS")
    MilTot = DSum("trp_mam", "qryTIMshtS")
    RTotal = HrsTot + MilTot
End Function

Three fields are on the report with:

=RAmont()
=RCount()
=RTotal()

The middle function works, but the other 2 do not. Can not, for the life of me, figure out why one works and the others do not. I spent over 4 hours now using every possible combination I know to make these work.

HELP!!!!

TBNK

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by TBotNik
0

All,

Found, contrary to normal math, that reports will not work if there is a null value anywhere. So code now reads:

Public HrsAmt, MilAmt, HrsTot, MilTot
Function RAmount()
    Dim FullAmount
    FullAmount = 0
    HrsAmt = DLookup("trp_ham", "qryTIMshtS", "[trp_id]=" & Me![Row_ID])
    If HrsAmt > 0 Then FullAmount = FullAmount + HrsAmt
    MilAmt = DLookup("trp_mam", "qryTIMshtS", "[trp_id]=" & Me![Row_ID])
    If MilAmt > 0 Then FullAmount = FullAmount + MilAmt
    RAmount = FullAmount
End Function
Function RCount()
    RCount = DCount("trp_id", "qryTIMshtS")
End Function
Function RTotal()
    HrsTot = DSum("trp_ham", "qryTIMshtS")
    MilTot = DSum("trp_mam", "qryTIMshtS")
    RTotal = HrsTot + MilTot
End Function

Which works.

Thanks all!!

TBNK

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.