Click to See Complete Forum and Search --> : Link to another form


dr223
March 4th, 2009, 05:41 AM
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

sotoasty
March 4th, 2009, 01:54 PM
Create a property on the FrmPayHistory called PracNo


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

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.