选择查询完美运行(访问2013)。一旦我将其更改为交叉表,它就会给出错误“条件表达式中的数据类型不匹配”。我在交叉表值中使用vba函数作为表达式。我的表中没有空值,并尝试使用variant作为我的数据类型。
VBA
Task
和SQL
enter code here
'assumes that the rate is monthly
Public Function payFrequency(frequency As String, rate As Currency) As Currency
If frequency = "BI-WEEKLY" Then
payFrequency = rate * 12 / 26
Exit Function
ElseIf frequency = "SEMI-MONTHLY" Then
payFrequency = rate * 12 / 24
Exit Function
ElseIf frequency = "MONTHLY" Then
payFrequency = rate
Exit Function
Else
payFrequency = 0
Exit Function
End If
End Function
答案 0 :(得分:0)
我建议您在查询中构建此函数,而不是VBA。无论如何,这将是我的首选解决方案;来自查询的VBA调用通常效率不高,并且可能更难以解决问题。