Hello everyone,
I have a main form which has couple of subforms bound to one main table. One of the subfomrs is about employment info. It has 3 TextBoxes: (Job Start Date), (Employer Name), and (Wage). It has also 3 ComboBoxes: (Job Type [Full Time or Part Time]), (Hire Status [Permanent or Temporary]), (Quarter [1st, 2nd, or 3rd]). I want to force users to fill all these 6 fields if they put any value in any one of them.
I tried to set a Validation Rule in the TextBox/ComboBox’s property including IIF statement condition, but I did not succeed, and these rules did not work.
I put the following code in the subform’s (After Update), (Before Update), and (On Current) events which works very well when I keep the (Wage) value 0 and move to a new record or to another subform:
Private Sub Form_AfterUpdate()
If Me.[Start Date] > 0 And Me.Wage.Value = 0 Then
MsgBox "Oops!! Sorry, you did not put how much is the wage."
Cancel = True
End If
End Sub
-----------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.[Start Date] > 0 And Me.Wage.Value = 0 Then
MsgBox "Oops!! Sorry, you did not put how much is the wage."
Cancel = True
End If
End Sub
-----------------------
Private Sub Form_Current()
If Me.[Start Date] > 0 And Me.Wage.Value = 0 Then
MsgBox "Oops!! Sorry, you did not put how much is the wage."
Cancel = True
End If
End Sub
I don’t know how to make a similar validation rule for the other TextBoxes and ComboBoxes. I highly appreciate any tip and help.
Thank you so much.. Anwar
I have a main form which has couple of subforms bound to one main table. One of the subfomrs is about employment info. It has 3 TextBoxes: (Job Start Date), (Employer Name), and (Wage). It has also 3 ComboBoxes: (Job Type [Full Time or Part Time]), (Hire Status [Permanent or Temporary]), (Quarter [1st, 2nd, or 3rd]). I want to force users to fill all these 6 fields if they put any value in any one of them.
I tried to set a Validation Rule in the TextBox/ComboBox’s property including IIF statement condition, but I did not succeed, and these rules did not work.
I put the following code in the subform’s (After Update), (Before Update), and (On Current) events which works very well when I keep the (Wage) value 0 and move to a new record or to another subform:
Private Sub Form_AfterUpdate()
If Me.[Start Date] > 0 And Me.Wage.Value = 0 Then
MsgBox "Oops!! Sorry, you did not put how much is the wage."
Cancel = True
End If
End Sub
-----------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.[Start Date] > 0 And Me.Wage.Value = 0 Then
MsgBox "Oops!! Sorry, you did not put how much is the wage."
Cancel = True
End If
End Sub
-----------------------
Private Sub Form_Current()
If Me.[Start Date] > 0 And Me.Wage.Value = 0 Then
MsgBox "Oops!! Sorry, you did not put how much is the wage."
Cancel = True
End If
End Sub
I don’t know how to make a similar validation rule for the other TextBoxes and ComboBoxes. I highly appreciate any tip and help.
Thank you so much.. Anwar