CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    192

    Link to another form

    Hallo,

    I have a form called FrmPracDetails, which has details of practices and each practice has a unique prac_no populated on the form in the text box called TxtPracNo.

    Now, I have another form called FrmPayHistory. This form has a datagrid called DgvPayHistory, which is loaded with all the payment history of all practices. It has also a field called prac_no and stores the unique prac_no.

    What I want to do is, when a user is in FrmPracDetails, lets say prac_no - 1155, then you open the FrmPayHistory. Only the payment history of that respective prac_no should be seen. Presently, it brings all the practices and their payment history.

    I have added a textbox (TextBox1) in the FrmPayHistory which links and displays the prac_no from FrmPracDetails with the following code;

    Me.TextBox1.Text = FrmPracDetails.TxtPracNo.Text

    Could anyone tell me the code for this? Thanks

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Link to another form

    Create a property on the FrmPayHistory called PracNo

    Code:
    Private mvarPracNo as String
    Public WriteOnly Property String PracNo()
      Set (ByVal value as String)
          mvarPracNo = value
          LoadData
      End Set
    End Property
    
    Private Sub LoadData()
      SQLCommand.CommandText = "SELECT * FROM Table WHERE ID=@ID"
      SQLCommand.Parameters.AddWithValue("@ID",mvarPracNo)
      ... execute your command and populate your data here
    End Sub
    In your calling form
    Code:
    Private Sub OpenHistoryForm()
      DIM OHF as new frmPayHistory
      OHF.PracNo = Me.TxtPracNo.Text
      OHF.ShowDialog()   ' Or Show() if defined in the form
    End Sub
    Now anytime you set the PracNo property of the frmPracPayHistory, the form will load the data of that ID.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured