Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forbid opening subform by itself 1

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
Can i forbid opening the subform by itself ? I want my subform to be opened only by the main form and i somebody wants to open the subform not to allow it
 
In the Open event procedure of the subform:
Code:
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim myObj As Object
Set myObj = Me.Parent
If myObj Is Nothing Then
  MsgBox "This subform should be open only by the main form"
  Cancel = True
End If
Set myObj = Nothing
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top