Question Validating a field based on the selection of another field (1 Viewer)

adewale4favour

Registered User.
Local time
Today, 08:49
Joined
Aug 9, 2019
Messages
55
Hello!,
I am Michael.
I will appreciate getting assisted in figuring this out.

I have a form with two Combo boxes, both are dependent. Now what I want to achieve is, Example, in Combo Box A TYPE, I have options like HP, Lenovo, Dell etc, and Combo box B, I have options like YEAR: Released 2003, Released 2005, Released 2008 etc. Now, I want users who select Lenovo to be mandated to select the year of released. If other options are selected, they can skip the year of released.

I thought this could be done from the Validation rule, I used this line of Validation:(([TYPE]="LENOVO" And [YEAR_RELEASED] Is Not Null) Or ([TYPE]<>"LENOVO" And [YEAR_RELEASED] Is Null))

This isn't working.

thanks
 

adewale4favour

Registered User.
Local time
Today, 08:49
Joined
Aug 9, 2019
Messages
55
thanks, but what I need is, users who select other options are free to proceed, but users who select LENOVO must select year else they should not be able to proceed.
the above option has been tried, only the sql query was not exactly this way, but most alike....
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:49
Joined
May 7, 2009
Messages
19,227
do it on the Form's BeforeUpdate event:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If [Type].ListIndex = -1 Then
    Cancel = True
    Msgbox "You need to select Type from combobox"
    Me.[Type].SetFocus

Else
    If [Type] = "Lenovo" And [Year_Release].ListIndex = -1 Then
        Cancel = True
        Msgbox "You need to specify the release year!"
        Me.[Year_Release].SetFocus
    End If
End If
End Sub
 

Users who are viewing this thread

Top Bottom