MS Access 2010 模块案例说明

MS Access 2010 Module Case Statement

我正在尝试在 MS Access 2010 中为 Birthday=5/5/1958 执行以下功能并获得 return 值 "unknown" 而不是 "Dog." 任何帮助这个 CASE 语句?

Public Function whichChineseZodiacSign(Birthday As Date)

Select Case whichChineseZodiacSign
Case #2/18/1958# To #2/7/1959#
    whichChineseZodiacSign = "Dog"

Case Else
    whichChineseZodiacSign = "Unknown"
End Select
End Function

谢谢!

试试这个:

Option Explicit

Public Function whichChineseZodiacSign(Birthday As Date) As String

    Select Case Birthday
    Case #2/18/1958# To #2/7/1959#
        whichChineseZodiacSign = "Dog"
    Case Else
        whichChineseZodiacSign = "Unknown"
    End Select

End Function

在你的情况下,你在 Select Case.

中有错误的条件