|
-
March 4th, 2009, 06:41 AM
#1
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
-
March 4th, 2009, 02:54 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|