I wrote a piece of code to test an issue with an iif() statement. I am getting an unexpected result. The code below displays 3 msg boxes (all with the expected data) instead of 2. What have I forgotten/ missed in this code?
Private Sub Command35_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim dtFieldValue As Date
Dim varHold As Variant
stDocName = "Contracts Tabbed Read Only2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, "Contracts Tabbed Read Only2", acGoTo, 10
dtFieldValue = Forms![Contracts Tabbed Read Only2].[Current Term Exp]
varHold = IIf(dtFieldValue < Date, MsgBox(dtFieldValue), MsgBox("false"))
MsgBox varHold
End Sub
Private Sub Command35_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim dtFieldValue As Date
Dim varHold As Variant
stDocName = "Contracts Tabbed Read Only2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, "Contracts Tabbed Read Only2", acGoTo, 10
dtFieldValue = Forms![Contracts Tabbed Read Only2].[Current Term Exp]
varHold = IIf(dtFieldValue < Date, MsgBox(dtFieldValue), MsgBox("false"))
MsgBox varHold
End Sub