dcsimg
Results 1 to 2 of 2

Thread: open form inside another form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    26

    open form inside another form

    i use this code to open form inside another form

    Code:
    Option Explicit
    Private Declare Function SetParent Lib "user32" _
      (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Public Function FormWithinForm(Parent As Object, _
       Child As Object)
    
    
    On Error Resume Next
    SetParent Child.hWnd, Parent.hWnd
    FormWithinForm = (Err.Number = 0 And Err.LastDllError = 0)
    
    End Function
    
    Private Sub new_Click()
    Form2.Show
    FormWithinForm Me, Form2
    
    End Sub
    i can only open 1 form2 but i need to be able to open multiple forms when i press on new_click

  2. #2
    Addicted Member
    Join Date
    Jun 2018
    Posts
    136

    Re: open form inside another form

    Change your code as follows...

    Code:
    Private Sub new_Click()
       Dim f2 As New Form2  
       FormWithinForm Me, f2
       f2.Show
    End Sub
    Another option would be MDIParent/MDIChild approach

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width