Hiding a null Control in Json string
On the tax labels in the Json code (Ms Access VBA) below, I want to hide the control field in Tax Class B if it does not contain a value in the final Json string or code. Currently it is showing a “Null” but unfortunately the machine cannot accept that, it should NEVER show at all cost.
If an event where all the two tax labels are having values then the actual labels attached to the controls must show the actual value, if not then no show.
Please check line 26 in the code below
If it was on an Ms Access Form, I can achieve this by doing it this way:
How about where VBA is feed Json, how can we withhold Null Values so that we avoid the Null values on the Json String? I tried the code below its NOT working at all.
If an event where all the two tax labels are having values then the actual labels attached to the controls must show the actual value, if not then no show.
Please check line 26 in the code below
{
"PosSerialNumber": "16777773",
"IssueTime": "20190101201045",
"TransactionType": 0,
"PaymentMode": 0,
"SaleType": 0,
"LocalPurchaseOrder": "ZRP568930082",
"Cashier": "CHRIS",
"BuyerTPIN": "199863289426",
"BuyerName": "Inspur",
"BuyerTaxAccountName": "Western Ville",
"BuyerAddress": "Eagles Nest ",
"BuyerTel": "+5869302179940",
"OriginalInvoiceCode": null,
"OriginalInvoiceNumber":null,
"Items": [
{
"ItemId": 1,
"Description": "Fruit Drink",
"BarCode": "783692456300",
"Quantity": 8,
"UnitPrice": 2,
"Discount": 0,
"TaxLabels": [
"A",
"null"
],
"TotalAmount": 16,
"isTaxInclusive": true,
"RRP": 0
}
]
}
If it was on an Ms Access Form, I can achieve this by doing it this way:
If IsNull(Me.TaxClassB)Then
Me.TaxCassB.Visible = False
End If
How about where VBA is feed Json, how can we withhold Null Values so that we avoid the Null values on the Json String? I tried the code below its NOT working at all.
Dim myvar As Variant
Tax.Add ( myvar = DLookup("TaxClassB", "QryJson", "InvoiceID =" & Me.InvoiceID & " AND ItemesID =" & CStr(i)))
If Not IsNull(myvar) Then
If Len(myvar) > 0 Then
Tax.Add myvar
End If
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.