Form opened stand alone or as a subform

R

Rick A

I've created a stand alone form. It works great. To eliminate duplication I want to use this form as a subform. Is there a way to know when the form is opened stand alone and when it is opened as a subform?

When the form is used as a subform I want to hide buttons and other controls.

Thanks,
 
B

Brendan Reynolds

Private Sub Form_Load()

Dim obj As Object

On Error GoTo ErrorHandler
Set obj = Me.Parent

Me.Label0.Caption = "I'm a subform!"

ExitProcedure:
Exit Sub

ErrorHandler:
Debug.Print Err.Number
If Err.Number = 2452 Then
Me.Label0.Caption = "I'm not a subform!"
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
Resume ExitProcedure

End Sub

--
Brendan Reynolds
Access MVP

I've created a stand alone form. It works great. To eliminate duplication
I want to use this form as a subform. Is there a way to know when the form
is opened stand alone and when it is opened as a subform?

When the form is used as a subform I want to hide buttons and other
controls.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top