E
Eka1618
Hello,
I have several forms (including subforms) that I want to loop through before
a person exits that form to check if all fields are not null.
I wanted to put this in a module and then call it again in each form where
needed.
I tried to call the function in the Lost Focus Event, but I'm not sure if
that would work when it comes to checking a subform and its parent form, so
then I tried the deavtivated event, and did not get anywhere...
I have text boxes, combo boxes and list boxes if that helps. I have posted
my code below. If anyone has any tips on what I can do, please let me know,
Thank you!
~Erica~
Here is the function I created in my module:
Public Function CheckIfNull(frm As Form) As Boolean
Dim ctrl As Control
CheckIfNull = False
For Each ctrl In frm.Controls
If ctrl Is Null Then
CheckIfNull = True
End If
Next
End Function
Here is a sample of code inside a form:
Private Sub Form_Deactivate()
Dim ctrlNull As Boolean
ctrlNull = CheckIfNull(Me)
If ctrlNull = True Then
MsgBox "You must fill out all fields in General Information before
moving on."
End If
End Sub
I have several forms (including subforms) that I want to loop through before
a person exits that form to check if all fields are not null.
I wanted to put this in a module and then call it again in each form where
needed.
I tried to call the function in the Lost Focus Event, but I'm not sure if
that would work when it comes to checking a subform and its parent form, so
then I tried the deavtivated event, and did not get anywhere...
I have text boxes, combo boxes and list boxes if that helps. I have posted
my code below. If anyone has any tips on what I can do, please let me know,
Thank you!
~Erica~
Here is the function I created in my module:
Public Function CheckIfNull(frm As Form) As Boolean
Dim ctrl As Control
CheckIfNull = False
For Each ctrl In frm.Controls
If ctrl Is Null Then
CheckIfNull = True
End If
Next
End Function
Here is a sample of code inside a form:
Private Sub Form_Deactivate()
Dim ctrlNull As Boolean
ctrlNull = CheckIfNull(Me)
If ctrlNull = True Then
MsgBox "You must fill out all fields in General Information before
moving on."
End If
End Sub