|
-
May 2nd, 2011, 09:10 AM
#1
Thread Starter
New Member
[RESOLVED] Storing Access 07 data on VB 08
I know that this is a stupid question but I really cannot work out how I can store data that's been read from a database as a variable that I can then work with in vb.
I've linked the two using the standard data sourcing method and I now need to use the data that is read in to it on another form.
The idea of this is that I'm creating a wage calculator and the employees are stored in a database and can be viewed on a vb form, however, I now need to use the data of their pay/hr to be used on another form to calculate the wage.
I have tried to declare a public variable across the two separate forms, and on the button that takes you to the other to set this variable as the contents of the text box which is displaying the pay/hr using the following code:
Public Class ManageUsers
Public HrlyRate As Decimal 'Declaring global variable to use between forms
'Some other code in between relating to rest of the stuff on the form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RatePerHourTextBox.Text = HrlyRate 'Saving private variable to global variable
Calculation.Show()
End Sub
End Class
Then on the other form I have used this code to do the calculation:
Public Class Calculation
Private Sub calculation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
'Coding for when the user clicks the 'Calculate' button
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click
Dim decIncome, decDeductions, decAmount As Decimal 'Creates three variables as real numbers
decIncome = ManageUsers.HrlyRate 'Sets income as hourly rate from other form
decDeductions = decIncome * 0.22 'Calculates decution of tax at 22%
decAmount = decIncome - decDeductions 'The final amount being Income subtract Deductions
lblIncFig.Text = Format(decIncome, "currency") 'This formats the output labels to £XXX.XX
lblDedFig.Text = Format(decDeductions, "currency")
lblFinFig.Text = Format(decAmount, "currency")
End Sub
Private Sub EmployeeBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.EmployeeBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Payroll_CheckerDataSet)
End Sub
End Class
I'm still really new to this program and this is needed before tomorrow, so if I could have an idiot answer that I could follow please and asap!! 
Much appreciated
Tags for this Thread
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
|