Full Version: Learning About Some Code Report
mkkashif
Dear Sir.

CRFlag Mean i guess this is field.
CRFlag=True Mean i don't know .
CDFlag i think this a Field in the Query.is this a field in table.

Code and Explanation

So to do what you are trying to do, you would use DSum to calculate the Beginning Balance by summing iif([CRFlag]=True, TransactionAmount, -TransactionAmount) where date < Your ReportBeginDate

For the debit and credit fields, you use a query containing TransactionTypeID, TransactionAmount and CDFlag. In two textboxes on your report.....For the Credit, you use the expression =iif([CRFlag]=True,[TransactionAmount],Null) and for the Credit, you use the expression =iif([CRFlag]=False, [TransactionAmount],Null)
For the Running balance, I'd calculate =[BeginningBalance=+iif([CRFlag]=True,[TransactionAmount],-TransactionAmount]

yvesdekort
Hi,

CRFlag is probably a field in a table (to be 100% sure, I need a bit more background an the db)
It probably is a boolean-type, this means it is either true or false.

So for the expression Credit = Iif([CRFlag]=True,[TransactionAmount],Null)
the value of CRFlag is compared to true,
so if CRFlag holds the value true, the Credit = TransactionAmount;
if CRFlag holds the value false, the Credit = Null

The CDFlag could be a typo (it probably should also be CRFlag), because it isn't mentioned afterwards; but again to be 100% sure, one would need a little more background.

hth
mkkashif
Thanks Dear Sir.

it's mean that there must be a field in the table with type YES/NO.
And it has Name CrFlag.and when do entries there we decide True/False.
Am i Right.
Can You See this .in Background this is the Thread.