Hello everybody.. Here I have a question regarding my “Budget System” project. It’s about to link the annual budget amount (txtBudget) from form 1 to the (txtBudget) in the form 2. It means that the system user have to set the value txtBudget in the form 1, so that it appears in the form 2 txtBudget, consequently to show the balance in txtBalance after being reducted using the MSFlexGrid codes below…

Private Sub cmdCalculate_Click()
Dim i As Integer
      Dim TAmt As Currency
      TAmt = 0
      For i = 1 To Grd.Rows - 1
         TAmt = TAmt + Val(Grd.TextMatrix(i, 7))
      Next
      TAmt = Val(txtBudget.Text) - TAmt
      txtBalance.Text = Format(TAmt, "0.00")
End Sub

Hope you can guide me, how to link the txtBudget value in these Form 1 and Form 2. Do I need to use module, or database otherwise? But how it is? I had reviewed the book and hardly thought about it, but I can’t find the answer..

Recommended Answers

All 3 Replies

I'm pretty sure the only way is to refer to the object and assign it directly. That is, something along the lines of:

form2.txtBudget.text = form1.txtBudget.text
commented: Works very well.. +1

Thanx bro for your useful info. It works well, that i used code as below, modifying the code u gave.

In form 1

Private Sub cmdConfirm_Click()
Dim Budget08 As Currency
Budget08 = TextBudget08.Text
Form1.Label11.Caption = Budget08
Form2.TextBudget08.Text = Budget08
End Sub

In form2

Private Sub cmdCalculate_Click()
Dim i As Integer
      Dim TAmt As Currency
      TAmt = 0
      For i = 1 To Grd.Rows - 1
         TAmt = TAmt + Val(Grd.TextMatrix(i, 7))
      Next
      TAmt = Val(TextStat08.Text) - TAmt
      txtBalance.Text = Format(TAmt, "0.00")
End Sub

But, the problem is...it doesn't save the amount that i key in for the next usage, that i have to re-key in the budget amount everytime i use the system. Should i need to store the annual budget amount (from form 1) in a database, then put the second Data, (Data2) on the form 2? But how's the code to link the budget amount from the certain table in the database, to the calculation code in the form 2, so that when i click the cmdCalculate, it can show the balance in the txtBalance? Plz bro, help me..

Ok, i've got the answer.. It's just about to link the TextBudget08 on each forms to the sama database.. It's that easy.. Hehe..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.