Derived from the Access 97 Developer's Handbook, (p503), there is a function which allows you to detect if the current form is loaded as a subform--very helpful, since you may want to, say, hide certain controls if the form is currently loaded as a subform.
Here is the function:
Function IsSubForm(frm as Form) as Boolean 'Is the form referenced in the parameter currently loaded 'as a subform? Check its Parent property to find out. Dim strName as String On Error Resume Next strname = frm.Parent.Name IsSubForm = (Err = 0) On Error GoTo 0 End Function
The code that would execute to perform the check:
If IsSubform(Me) Then 'It's a subform Else 'It is NOT a subform End If