I have a form, F_Project, that I want to force the user to fill in certain fields before the form record can be saved. Namely, Project Name, Engineer Name, & Project Phase. I have a Public Function that checks to see if there is anything in these, and that function is in the BeforeUpdate event of the form. This all works good. See attached snip.
I would like to add to the Public Function, that the Location is filled in as well. The problem is the Location combo is in a subform on F_Project.
Here's my Public Function:
Is there a way to add this by adding to the Public Function line something like this?
Or perhaps I'm not thinking of this correctly. Is a subform considered a control or just an object on the parent form?
I do have another way this is accomplished but I am trying to get it all taken care of with the Public Function in order to be a cleaner solution enabling it to all be within the BeforeUpdate event.
Thanks for any help.
I would like to add to the Public Function, that the Location is filled in as well. The problem is the Location combo is in a subform on F_Project.
Here's my Public Function:
Code:
Public Function ValidationOfControl(frm As Access.Form) As Boolean
'This function requires the user to provide data to Combo and Text boxes that have a * in the Tag property.
Dim nl As String, ctl As Control
Dim boolResult As Boolean
nl = vbNewLine & vbNewLine
For Each ctl In frm.Controls
If ctl.ControlType = acComboBox Or ctl.ControlType = acTextBox Then
If ctl.Tag = "*" And Len(ctl.Value & "") = 0 Then
ctl.SetFocus
boolResult = True
Exit For
End If
End If
Next ctl
ValidationOfControl = boolResult
End Function
Is there a way to add this by adding to the Public Function line something like this?
Code:
If ctl.ControlType = acComboBox Or ctl.ControlType = acTextBox Or ctl.ControlType = acForm Then
Or perhaps I'm not thinking of this correctly. Is a subform considered a control or just an object on the parent form?
I do have another way this is accomplished but I am trying to get it all taken care of with the Public Function in order to be a cleaner solution enabling it to all be within the BeforeUpdate event.
Thanks for any help.