I have a small if statement I built here:
Basically it assigns a true/false value to a boolean variable based on the value of a combo box. If one of the 3 required boxes are null, it tells the user that the boxes cannot be null and then it sets focus to the box which is null.
Taking this a step further and also because I can use this knowledge in other areas of my database, I would like to know how to be able to tell the user "Equipment Status cannot be empty!" Or, "Model Number cannot be empty!" etc. etc.
...How is this done?
Code:
If Nz(Me.cboEquipmentStatus, "") = "" _
Or Nz(Me.cboEquipmentModelNum, "") = "" _
Or Nz(Me.txtSerialNum, "") = "" Then
MsgBox "Equipment Status, Model Number, and Serial Number cannot be empty!", vbOKOnly
If Nz(Me.cboEquipmentStatus, "") = "" Then
Me.cboEquipmentStatus.SetFocus
ElseIf Nz(Me.cboEquipmentModelNum, "") = "" Then
Me.cboEquipmentModelNum.SetFocus
ElseIf Nz(Me.txtSerialNum, "") = "" Then
Me.txtSerialNum.SetFocus
End If
Exit Sub
Else
If Me.cboEquipmentStatus.Value = 2 Then
addStorage = True
ElseIf Me.cboEquipmentStatus.Value = 1 Then
addStorage = False
End If
End If
Taking this a step further and also because I can use this knowledge in other areas of my database, I would like to know how to be able to tell the user "Equipment Status cannot be empty!" Or, "Model Number cannot be empty!" etc. etc.
...How is this done?
Comment