I did the below and apologize for me not catching your wording as i figured it would work as a defined function.. this has no issues but does not catch the empty text box.. also when you use len it is to cont characters so why is there a & "" added?
this will work by itself
but not when i make it an and statement
this will work by itself
Code:
If (Len(Forms!WindOptOutV12.IndStatmentHandwrittenComment & "") = 0) Then
but not when i make it an and statement
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim blnError As Boolean
Dim strError As String
If (Forms!WindOptOutV12.IndStatmentHandwrittenComment = -1 And Len(Forms!WindOptOutV12.IndStatmentHandwrittenComment & "") = 0) Then
blnError = True
strError = "Other Deviations Comment" & vbCrLf
End If
'If Len(Me.AnotherControlNameHere & "") = 0 Then
' blnError = True
' strError = strError & "YourOtherControlNameHere" & vbCrLf
'End If
' and so on for how ever many controls you want to validate that
'something has been entered. You can also validate other stuff about the values, etc.
If blnError Then
Cancel = True
If MsgBox("You need to fill out these fields before we can save the record: " & vbCrLf & _
strError & vbCrLf & _
"Do you wish to cancel this record?", vbQuestion + vbYesNo, "Validation Failure") = vbYes Then
Me.Undo
End If
End If
End Sub