Required field

Jagged

Registered User.
Local time
Today, 03:04
Joined
Aug 21, 2013
Messages
10
Hi


Anyone have a solution for this?

I have a form with a combobox on it with 9 different possible outcoms. What I want to achieve is that if the user has selected one of 3 specific outcomes then there is another field on the form that is required. If none of them has been selected then the field isn't required.

How do set up the check for the specific value?
 
Use the Form Before Update event..
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.[COLOR=Blue]yourComboBoxName[/COLOR].ListIndex <> -1 Then
        Select Case Me.[COLOR=Blue]yourComboBoxName[/COLOR]
            Case "[COLOR=Red]Option 1[/COLOR]", "[COLOR=Red]Option 2[/COLOR]", "[COLOR=Red]Option 3[/COLOR]"
                If Len(Me.[COLOR=Blue]theRequiredControlName [/COLOR]& vbNullString) = 0 Then
                    MsgBox "This is a Requierd value, as you have selected " & Me.[COLOR=Blue]yourComboBoxName[/COLOR], vbCritical, "Please Retry"
                    Me.[COLOR=Blue]theRequiredControlName[/COLOR].SetFocus
                    Cancel = True
                End If
        End Select
    End If
End Sub
Change names to match your design.
 

Users who are viewing this thread

Back
Top Bottom