Set Calling FORM Visible = False by CALLED FORM

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    Set Calling FORM Visible = False by CALLED FORM

    Hullo Good Friends,
    I need your help. Please Help me.

    I am trying to pass the name of the Calling FORM FRMSALES to the Loaded FORM FRMPOPUPCustome rs so that FRMPOPUPCustome r will set the FRMSALES visible to FALSE.

    I am not sure how to do it. FRMPOPUPCustmer does not turn FRMSALES visible to FALSE.

    Here are the coding from Both FORMs:

    Code:
    '--------------------------------------------------------------
    ' FORM		: FRMSALES.VB
    ' Description	: This form load FrmPOPUPCustomer to retrieve specific customer
    '		   or Create New Customer
    '----------------------------------------------------------------
    
     Private Sub  ToolStripMenuItem_Click(ByVal sender As System.Object, _
                      ByVal e As System.EventArgs) _
                      Handles ToolStripMenuItem.Click
    
            Dim FM As New FrmCityRef
            Dim callFrm As New FrmCustMaint
             
            FM.PropCallForm = callFrm
            FM.ShowDialog()
            FM = Nothing
     
     End Sub
    Code:
    '------------------------------------------------------------
    ' FORM 		:FRMPOPUPCUSTOMER.VB
    ' Description	: This form uses DataGridView and TEXTBOX to create new customer record
    '             : It will set the CALLING FORM visible to FALSE
    ' --------------------------------------------------------------
    Option explicit ON
    Dim  FrmCall As Form
    
      Private Sub FRMPOPUPCUSTOMER_Load(ByVal sender As System.Object, _
    	ByVal e As System.EventArgs) _
            Handles MyBase.Load
    
             FrmCall.Visible = False     
        End Sub
    
    Public Property PropCallForm() As Form
            'retrieve calling form name to set visible off
            Get
                Return FrmCall
            End Get
    
            Set(ByVal value As Form)
                FrmCall = value
            End Set
     End Property
    
     Private Sub FRMPOPUPCUSTOMER_FormClosed(ByVal sender As Object, _
    	ByVal e As System.Windows.Forms.FormClosedEventArgs) _
    	Handles Me.FormClosed
    
            FrmCall.Visible = True
    
    End Sub
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    I think you are pretty close to getting this working. I believe your problem is with the form that you are passing to the called form. In your ToolStripMenuIt em_Click code, you have the following lines of code:

    Code:
             Dim FM As New FrmCityRef
             Dim callFrm As New FrmCustMaint
      
             FM.PropCallForm = callFrm
             FM.ShowDialog()
             FM = Nothing
    Notice that what you are doing is creating a NEW FrmCustMaint form and passing it to the called form. When you use the keyword "New" it creates a new object that has no relationship to any forms that are currently being displayed. I assume that the ToolStripMenuIt em_Click method is a member of the form that you wish to hide. If so, instead of creating a new form and passing that in you need to pass in Me:
    Code:
             Dim FM As New FrmCityRef
      
             FM.PropCallForm = Me
             FM.ShowDialog()
             FM = Nothing

    Comment

    • lenniekuah
      New Member
      • Oct 2006
      • 126

      #3
      Hi Joseph Martell
      Thank you very much for your suggestion. I did try it out and it's working.
      I have to modify it to suit our setup.

      I would like to post it here to share it with others who may have similar problems and need help.
      Code:
      Private Sub btnCustomer_Click(ByVal sender As System.Object, 
      	ByVal e As System.EventArgs) Handles btnCustomer.Click
      
              Dim FM As New FrmCustMaint
              Dim callFrm As System.Windows.Forms.Form = Me
      
              FM.PropCallForm = callFrm
              FM.ShowDialog()
              FM = Nothing
          End Sub
      ---------------------------------------
      Code:
      Option Explicit On
      
      Public Class FrmCustMaint
      
      	Dim FrmCall As System.Windows.Forms.Form
      
      	 Private Sub FrmCustMaint_Load(ByVal sender As System.Object, 
      		ByVal e As System.EventArgs) Handles MyBase.Load
              
              		FrmCall.Visible = False
      	End sub
      
       	Public Property PropCallForm()
              		Get
                  			Return FrmCall
              		End Get
              		Set(ByVal value)
                 			 FrmCall = value
              		End Set
          	End Property
      
      End Class

      Comment

      Working...