简体   繁体   English

拆分一个数组并使用它来引用另一个表并对另一个相关字段求和

[英]Split an array and use that to reference another table and sum another related field

In Access, I have an array of division numbers from a MultiSelect list that is in a text box as an comma delimited array.在 Access 中,我有一个 MultiSelect 列表中的分区号数组,该列表以逗号分隔的数组形式位于文本框中。 I would like to split the array.我想拆分数组。 Once split, I'd like you use the division numbers to reference a division table and add number of stores related to each division.拆分后,我希望您使用部门编号来引用部门表并添加与每个部门相关的商店数量。 The table has Division 1, Number of Stores 10, Division 2, Number of Stores 20该表有部门 1,商店数量 10,部门 2,商店数量 20

I've tried to split the array and I don't know where to go from there.我试图拆分数组,但我不知道从那里到 go 的位置。

Private Sub Stores_Impacted_Click()

    Dim TextString As String
    Dim Result() As String
    TextString = Me!mySelections.Value
    Result = Split(TextString, " ")
    Dim item As Variant
    For Each item In Result
  
    Next item
End Sub

You can use DCount and a single code line:您可以使用DCount和单个代码行:

    For Each item In Result
        Debug.Print DCount("*", "DivisionTable", "Division = '" & item & "'")
    Next item

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM