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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.