如何隐藏控件而不在Json字符串中进行记录 [英] How to hide controls without record in Json string

查看:76
本文介绍了如何隐藏控件而不在Json字符串中进行记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,以确保如果Ms Access记录源显示空白/空记录,请确保Json字符串中的某些控件不出现在字符串上,如下所示:

I need some help on how to make sure that some controls in Json string should not appear on the string if the Ms Access record source is showing blank/Empty record see below:

[
   {
      "ItemNumber": 1,
      "SalesDate": "2019-09-14",
      "ProductName": "Pepsi (Rgb 350 ML)",
      "BarCode": "6009803227328",
      "Qty": 165,
      "Price": 53.5,
      "VAT": Null
      "TotalPrice": 10239.9
   },

让我们假设MS Access记录源中的增值税控制为空/空白,则字符串应如下所示:

Let us assume VAT control in MS Access record source is empty/blank, then the string should look like below:

[
   {
      "ItemNumber": 1,
      "SalesDate": "2019-09-14",
      "ProductName": "Pepsi (Rgb 350 ML)",
      "BarCode": "6009803227328",
      "Qty": 165,
      "Price": 53.5,
      "TotalPrice": 10239.9
   },

请看看是否有可能解决这个问题。

Kindly see if it is possible to sort out this.

下面是提供Json字符串的示例实际VBA代码。假设B类税为EMPTY / BLANK,而不是在阵列中显示空值,我不希望它在此处显示任何内容:

Below is the sample actual VBA code that supply the Json string. Assuming Tax Class B is EMPTY/BLANK instead of showing null in the ARRAY I do not want it to show anything here:

 Tax.Add DLookup("TaxClassA", "QryJson", "InvoiceID =" & Me.InvoiceID & " AND ItemesID =" & CStr(i))
    Tax.Add DLookup("TaxClassB", "QryJson", "InvoiceID =" & Me.InvoiceID & " AND ItemesID =" & CStr(i))


推荐答案

如果您只想在Tax中添加不为null或空白的值,请在致电Tax.Add之前检查这些条件。

If you only want to add the value to Tax if it is not null or blank, then check for those conditions before calling Tax.Add.

Dim myvar As Variant

    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

注意:从记录中逐个获取一组值是较慢的方法。您可能需要查看DAO(或ADO,具体取决于应用程序),它可以使您一次获取完整记录。

Note: Getting a set of values from a record one by one is the slow way. You may want to look at DAO (or ADO depending on the application) which allows you to get an entire record at once.

这篇关于如何隐藏控件而不在Json字符串中进行记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆