P
Pace
I have a form on which there are a list of questions.
A combo box gives the list of possible answers and a comment box will appear
when certain answers are given. I need to force the user to put something in
the comments boxes when they are displayed.
I have tried putting the following code in the Forms BeforeUpdate and
AfterUpdate properties and also on the Command button that takes the user to
the next form but nothing seems to work and the form simply closes.
Obviously I've got it wrong somewhere - can anyone please help?
Dim Myform As Form
Dim ctl As Object
Set Myform = Screen.ActiveForm
For Each ctl In Myform.Controls
'Only check text boxes.
Select Case ctl.ControlType
Case acTextBox
If ctl.Visible = True And Len(ctl.Value) = 0 Or Ctl.visible = True And
ctl.Value = "" Then
MsgBox "You must enter a comment", vbCritical, "Missing Data"
Cancel = True
End If
Exit For
End Select
Next ctl
A combo box gives the list of possible answers and a comment box will appear
when certain answers are given. I need to force the user to put something in
the comments boxes when they are displayed.
I have tried putting the following code in the Forms BeforeUpdate and
AfterUpdate properties and also on the Command button that takes the user to
the next form but nothing seems to work and the form simply closes.
Obviously I've got it wrong somewhere - can anyone please help?
Dim Myform As Form
Dim ctl As Object
Set Myform = Screen.ActiveForm
For Each ctl In Myform.Controls
'Only check text boxes.
Select Case ctl.ControlType
Case acTextBox
If ctl.Visible = True And Len(ctl.Value) = 0 Or Ctl.visible = True And
ctl.Value = "" Then
MsgBox "You must enter a comment", vbCritical, "Missing Data"
Cancel = True
End If
Exit For
End Select
Next ctl