wajidpharmacist007
Member
- Local time
- Today, 03:25
- Joined
- Nov 23, 2018
- Messages
- 31
Hi, I am new to vba programming and i dont know much basics about vba. I want to make the function that shows the status of purchase order just like this
I call this code in query column in this way
Purchase Order Status: POStatus([ApprovalStatus],[Item_PO_Qty],[GRN_Qty])
This code works well for first two If statements but for the last three If statement this does not works correctly
Please guide
Code:
Function POStatus(VarApprovalStatus, Item_PO_Qty, GRN_Qty)
If VarApprovalStatus = 3 Then
POStatus = "PO Cancelled"
ElseIf VarApprovalStatus = 2 Then
POStatus = "PO Rejected"
ElseIf VarApprovalStatus = 1 And GRN_Qty = Item_PO_Qty Then
POStaus = "Supplies Received"
ElseIf VarApprovalStatus = 1 And GRN_Qty < Item_PO_Qty Then
POStaus = "Supplies Pending"
ElseIf VarApprovalStatus = 1 And GRN_Qty > Item_PO_Qty Then
POStaus = "Extra Supply Received"
Else
POStatus = "Payment Pending"
End If
End Function
I call this code in query column in this way
Purchase Order Status: POStatus([ApprovalStatus],[Item_PO_Qty],[GRN_Qty])
This code works well for first two If statements but for the last three If statement this does not works correctly
Please guide