Here's a quick little function that will check if a control exists on a form or subform and return a boolean value.
I've used it to check to see if recordset field names are used as form control names, updating the recordset with the form value when I have a match (let me know if anyone is interested in that).
Here are the calls
No sub:
ControlExists(control.Name, form.Name)
With sub:
ControlExists(control.Name, subform.Name, True, subform.Parent.Name)
I've used it to check to see if recordset field names are used as form control names, updating the recordset with the form value when I have a match (let me know if anyone is interested in that).
Here are the calls
No sub:
ControlExists(control.Name, form.Name)
With sub:
ControlExists(control.Name, subform.Name, True, subform.Parent.Name)
Code:
Function ControlExists(ControlName As String, FormName As String, _
Optional blnSubform As Boolean, Optional strParentform As String) As Boolean
Dim strTest As String
On Error Resume Next
Select Case blnSubform
Case True
strTest = Forms(strParentform)(FormName).Form(ControlName).Name
ControlExists = (Err.Number = 0)
Case Else
strTest = Forms(FormName)(ControlName).Name
ControlExists = (Err.Number = 0)
End Select
End Function