rabbit2323
New member
- Local time
- Today, 13:22
- Joined
- Aug 16, 2021
- Messages
- 6
In my query, I have following fields: PayTerm, InvDate, DateMature, ETD, ETA, and DueDate. Base on the payment term, I'm trying to have database auto-calculate the Due Date in the query. Then update the due date in the table. The problem is that I have many payment terms. I try to fit them all in one iif statement, but the database doesn't allow it. So I created 3 different queries to accomplish the task. Then I created update qry for each one to update the table. I prefer not to have multiple queries to calculate the due date. Do you have a solution where I can use just 1 query? Or maybe create a VBA code for it where I can use it in access form?
Below is my iif statement:
DueDate: IIf([DateMature] Is Not Null,[DateMature],
IIf([PayTerm]="SIGHT DP",[InvDate]+14,
IIf([PayTerm]="SIGHT LC",[InvDate]+14,
IIf([PayTerm]="SIGHT TT",[InvDate]+14,
IIf([PayTerm]="LC 60 Days After BL DATE",[ETD]+60,
IIf([PayTerm]="LC 90 Days After BL DATE",[ETD]+90,
IIf([PayTerm]="TT 0 Days After ARRIVAL",[ETA],
IIf([PayTerm]="TT 0 Days After CUSTOMS CLEARANCE",[ETA],
IIf([PayTerm]="TT 10 Days After BL DATE",[ETD]+10,
IIf([PayTerm]="TT 30 Days After BL DATE",[ETD]+30,
IIf([PayTerm]="TT 30 Days After INVOICE DATE",[InvDate]+30,
IIf([PayTerm]="TT 40 Days After BL DATE",[ETD]+40,
IIf([PayTerm]="TT 45 Days After BL DATE",[ETD]+45,
IIf([PayTerm]="TT 60 Days After BL DATE",[ETD]+60,
IIf([PayTerm]="20% DEPOSIT 80% TT UPON ARRIVAL",[ETA],
IIf([PayTerm]="30% DEPOSIT 70% TT UPON ARRIVAL",[ETA],
IIf([PayTerm]="NET 7 Days After Invoice Date",[InvDate]+7
)))))))))))))))))
Below is my iif statement:
DueDate: IIf([DateMature] Is Not Null,[DateMature],
IIf([PayTerm]="SIGHT DP",[InvDate]+14,
IIf([PayTerm]="SIGHT LC",[InvDate]+14,
IIf([PayTerm]="SIGHT TT",[InvDate]+14,
IIf([PayTerm]="LC 60 Days After BL DATE",[ETD]+60,
IIf([PayTerm]="LC 90 Days After BL DATE",[ETD]+90,
IIf([PayTerm]="TT 0 Days After ARRIVAL",[ETA],
IIf([PayTerm]="TT 0 Days After CUSTOMS CLEARANCE",[ETA],
IIf([PayTerm]="TT 10 Days After BL DATE",[ETD]+10,
IIf([PayTerm]="TT 30 Days After BL DATE",[ETD]+30,
IIf([PayTerm]="TT 30 Days After INVOICE DATE",[InvDate]+30,
IIf([PayTerm]="TT 40 Days After BL DATE",[ETD]+40,
IIf([PayTerm]="TT 45 Days After BL DATE",[ETD]+45,
IIf([PayTerm]="TT 60 Days After BL DATE",[ETD]+60,
IIf([PayTerm]="20% DEPOSIT 80% TT UPON ARRIVAL",[ETA],
IIf([PayTerm]="30% DEPOSIT 70% TT UPON ARRIVAL",[ETA],
IIf([PayTerm]="NET 7 Days After Invoice Date",[InvDate]+7
)))))))))))))))))