If Me.xx.Text = "" Then
MsgBox "عفواً لا يمكن ترك هذا الحقل فارغاً", vbCritical, "تحذير"
Cancel = True
End If
في حدث عند الخروج من الحقل ضع الكود السابق حيث xx هو الحقل المراد إجبار المستخدم على عدم تركه فارغا
وهذا كود للأستاذ الفاضل أبو آدم جزاه الله خيرا وأحسن الله إليه
منعاً لترك أي حقل ( مربع نص أو مربع تحرير وسرد ) فارغاً ، خلف زر أمر للتدقيق ، ضع الكود التالي :
Private Sub cmdChick_Click()
Dim ctl As Control
Dim vIndex As Long
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or acComboBox Then
With ctl
If IsNull(Me.Controls.Item(vIndex)) = True Then
MsgBox vIndex & ": " & Me.Controls.Item(vIndex).Name & " Value:Empty Field"
Me.Controls.Item(vIndex).SetFocus
Exit Sub
End If
End With
End If
'This is used to track the actual Item Number.
vIndex = vIndex + 1
Next ctl
End Sub