Function IsControl (FrmName, sfName, CtrlName)

'This Function Tests to be certain Control on a Form or a Subform has a Value,
'If not, returns FALSE, If so, Returns TRUE
'
'Arguments:     CtrlName - Text String of the Control to be tested
'               FrmName  - Text String of the Form on which the Control or Subform Exists
'               sfName   - Optional Text String of Subform on which Control Exists
'
'Note: If there is no SubForm, you must specify NULL between the commas
'
'   Example1: IsControl("MyForm","MySubForm","MyControl")
'   Example2: IsControl("MyForm",NULL,"MyControl")
'
'Variable Declaration*************

Dim TestValue As Variant    'Used to force Error if Ctrl_Name has No Value
Dim sfControl As Control    'The Control in which the Subform, if any, exists
Dim Ctrl_Name As Control    'The name of the Control which needs to be tested

On Error GoTo NotExist

If Not IsNull(sfName) Then          'This routine is when a Subform exists

    Set sfControl = Forms(FrmName).Form(sfName)
    Set Ctrl_Name = sfControl.Form(CtrlName)
    TestValue = Ctrl_Name           'If Object has no Value, Error Occurs here.
                                    'Branches to NotExist
    IsControl = True
    Exit Function

Else                                'This routine is where SubForm argument is NULL

    Set Ctrl_Name = Forms(FrmName).Form(sfName)
    TestValue = Ctrl_Name           'If Object has no Value, Error Occurs here.
                                    ''Branches to NotExist
    IsControl = True
    Exit Function

End If

NotExist:

IsControl = False
Exit Function

End Function

