【发布时间】:2016-10-28 17:39:29
【问题描述】:
包含 3000 条记录和 21 列字段的表
我需要使用 2 个列字段(Field2 和 Field3)循环遍历记录,其中有一个空值来生成一个新列字段(Field4) 我从下面的这个函数开始,但我被卡住了,因为 case select 不能接受 null- 或者我可能需要使用我不擅长的嵌套 iif。
样本表
Name(Field1) Parts(Field2) Categories(Field3) New Field(Field4)
1 A1 R1 Inventory
2 A1 Null Inventory
3 B1 R1 Processing
4 B1 R4 Processing
5 B1 Null Unknown
6 Null Null Unknown
我的功能:
Function MachineCheck(Field2, Field3) As String
Dim newValue As String
Select Case (Field2)
Case "A1":
Select Case (Field3)
Case "R1"
newValue = "Inventory"
Case Is null
newValue = "Inventory"
Case "R1"
newValue = "Inventory"
Case “ “
newValue = "Inventory"
Select Case (Field2)
Case “B1”
End Select
MachineCheck = newValue
End Function
感谢您的帮助!
【问题讨论】:
-
你不必遍历记录的集合,你必须编写适当的查询!
-
一个查询调用了这个函数
-
状态:MachineCheck ([Field2], [Field3])