0
我試圖用一個Select Case
來評估TempVar
字符串值,但這種情況是不給我正確的結果。TempVars的在選擇案例
我的VBA代碼至今:
Private Sub Form_Load()
Select Case TempVars!CurrentStatus
Case Entered
'code to disable some controls
Case In Progress
'code to disable some controls
Case Ready to Approve
'code to disable some controls
Case Approved
'code to disable some controls
Case Else
Call MsgBox("Case statement didn't catch", vbInformation, "Tempvar test for case statements")
End Select
End Sub
的TempVar
被設置爲另一種形式如下:
Dim StrUserInput1 As String
TempVars("CurrentStatus").Value = DLookup("Status", "Control", "Status = '" & StrUserInput1 & "'")
'This is set by comparing the user input vs allowed status (for reports which is yet to be implemented)
我已經嘗試設置Case
爲Case "Entered"
,但它始終選擇第一種情況,而不是正確的。如果上面格式爲秀,結果是Case Else
任何人都可以提供關於爲什麼或如何我沒有得到正確的結果一些見解?
將沒有錯誤編譯沒有'選項Explicit' – SeanC
@SeanCheshire - 是啊,我一直以爲'選項正在使用Explicit',你看到這讓我。 – LittleBobbyTables
感謝您的幫助,需要更頻繁地使用「Option Explicit」:S – Deafdan