Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Dsum and iif on report

Experts,

I am trying to combine the below in an unbound field on a report.
Maybe its better to do it by VBA?  
Not sure which way is easier.

thank you...

In English:
If tblLetterOfCredit.PaidInFullYN = True then "Paid In Full", if not then Dsum but only if tblPayments.PaymentDate is not null (meaning there is a date entered)

--------------------------------------
If tblLetterOfCredit.PaidInFullYN = True then "Paid in Full"
Else:

If is not null [PaymentDate] then Dsum [Amount].  How to add Is Not Nulll to below?
=iif(DLookUp("[PaymentDate]","tblPayments","[LCID] = " & [LetterOfCreditID]
dsum("[Amount]","tblPayments","[LCID] = " & [LetterOfCreditID]
Avatar of Daniel Pineault
Daniel Pineault

Perhaps something like
IIF(
	[PaidInFullYN] = True,
	"Paid In Full",
	IIF(
		IsNull([PaymentDate]) = True,
		"WhatToPutIfPaymentDateIsNull???",
		DSum("[Amount]", "tblPayments", "[LCID] = " & [LetterOfCreditID])
	)
)

Open in new window

Avatar of pdvsa

ASKER

Hi Daniel,

Thank you for your response.  Its pretty close.  
Could you kindly assist to add a Dlookup to reference tblPayments.[PaymentDate] since this field is not in my query and if I pulled tblPayments in then the grouping wouldn’t be how I need it.  I hope I have explained correctly.
<WhatToPutIfPaymentDateIsNull???
=> think 0 but will have to test (I dont want it to sum the [Amount] for that record).
this is how I have it now (only replaced WhatToPutIfPaymentDateIsNull with 0) :
=IIf([PaidInFullYN]=True,"Paid In Full",IIf(IsNull([PaymentDate])=True,0,DSum("[Amount]","tblPayments","[LCID] = " & [LetterOfCreditID])))

thank you
SOLUTION
Avatar of Daniel Pineault
Daniel Pineault

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdvsa

ASKER

Hi Daniel, looks good.  It works!  I thank you very much.  Have  good day...stay safe.
Any time and you as well!