By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,565 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Set Calling FORM Visible = False by CALLED FORM

100+
P: 126
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 FRMPOPUPCustomers so that FRMPOPUPCustomer 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:

Expand|Select|Wrap|Line Numbers
  1. '--------------------------------------------------------------
  2. ' FORM        : FRMSALES.VB
  3. ' Description    : This form load FrmPOPUPCustomer to retrieve specific customer
  4. '           or Create New Customer
  5. '----------------------------------------------------------------
  6.  
  7.  Private Sub  ToolStripMenuItem_Click(ByVal sender As System.Object, _
  8.                   ByVal e As System.EventArgs) _
  9.                   Handles ToolStripMenuItem.Click
  10.  
  11.         Dim FM As New FrmCityRef
  12.         Dim callFrm As New FrmCustMaint
  13.  
  14.         FM.PropCallForm = callFrm
  15.         FM.ShowDialog()
  16.         FM = Nothing
  17.  
  18.  End Sub
  19.  
  20.  
Expand|Select|Wrap|Line Numbers
  1. '------------------------------------------------------------
  2. ' FORM         :FRMPOPUPCUSTOMER.VB
  3. ' Description    : This form uses DataGridView and TEXTBOX to create new customer record
  4. '             : It will set the CALLING FORM visible to FALSE
  5. ' --------------------------------------------------------------
  6. Option explicit ON
  7. Dim  FrmCall As Form
  8.  
  9.   Private Sub FRMPOPUPCUSTOMER_Load(ByVal sender As System.Object, _
  10.     ByVal e As System.EventArgs) _
  11.         Handles MyBase.Load
  12.  
  13.          FrmCall.Visible = False     
  14.     End Sub
  15.  
  16. Public Property PropCallForm() As Form
  17.         'retrieve calling form name to set visible off
  18.         Get
  19.             Return FrmCall
  20.         End Get
  21.  
  22.         Set(ByVal value As Form)
  23.             FrmCall = value
  24.         End Set
  25.  End Property
  26.  
  27.  Private Sub FRMPOPUPCUSTOMER_FormClosed(ByVal sender As Object, _
  28.     ByVal e As System.Windows.Forms.FormClosedEventArgs) _
  29.     Handles Me.FormClosed
  30.  
  31.         FrmCall.Visible = True
  32.  
  33. End Sub
  34.  
  35.  
  36.  
  37.  
Sep 6 '10 #1

✓ answered by Joseph Martell

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 ToolStripMenuItem_Click code, you have the following lines of code:

Expand|Select|Wrap|Line Numbers
  1.          Dim FM As New FrmCityRef
  2.          Dim callFrm As New FrmCustMaint
  3.  
  4.          FM.PropCallForm = callFrm
  5.          FM.ShowDialog()
  6.          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 ToolStripMenuItem_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:
Expand|Select|Wrap|Line Numbers
  1.          Dim FM As New FrmCityRef
  2.  
  3.          FM.PropCallForm = Me
  4.          FM.ShowDialog()
  5.          FM = Nothing

Share this Question
Share on Google+
2 Replies


Joseph Martell
Expert 100+
P: 196
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 ToolStripMenuItem_Click code, you have the following lines of code:

Expand|Select|Wrap|Line Numbers
  1.          Dim FM As New FrmCityRef
  2.          Dim callFrm As New FrmCustMaint
  3.  
  4.          FM.PropCallForm = callFrm
  5.          FM.ShowDialog()
  6.          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 ToolStripMenuItem_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:
Expand|Select|Wrap|Line Numbers
  1.          Dim FM As New FrmCityRef
  2.  
  3.          FM.PropCallForm = Me
  4.          FM.ShowDialog()
  5.          FM = Nothing
Sep 7 '10 #2

100+
P: 126
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnCustomer_Click(ByVal sender As System.Object, 
  2.     ByVal e As System.EventArgs) Handles btnCustomer.Click
  3.  
  4.         Dim FM As New FrmCustMaint
  5.         Dim callFrm As System.Windows.Forms.Form = Me
  6.  
  7.         FM.PropCallForm = callFrm
  8.         FM.ShowDialog()
  9.         FM = Nothing
  10.     End Sub  
---------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Option Explicit On
  2.  
  3. Public Class FrmCustMaint
  4.  
  5.     Dim FrmCall As System.Windows.Forms.Form
  6.  
  7.      Private Sub FrmCustMaint_Load(ByVal sender As System.Object, 
  8.         ByVal e As System.EventArgs) Handles MyBase.Load
  9.  
  10.                 FrmCall.Visible = False
  11.     End sub
  12.  
  13.      Public Property PropCallForm()
  14.                 Get
  15.                         Return FrmCall
  16.                 End Get
  17.                 Set(ByVal value)
  18.                         FrmCall = value
  19.                 End Set
  20.         End Property
  21.  
  22. End Class 
Sep 8 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.