I have a problem with modifying data in an access database. The Db contains a Balance field which I want to be able to add amounts to. This is as far as I have gotten
The GUI has 3 three text boxes, one containing the current balance, second contains amount to be added and the third displays the new balance. I am unsure of how to retrieve the current balance and save it again! Any help would be greatly appreciated!
I am getting an error on this line of code also
Please help
VB.NET:
Public Class Deposit
Dim objDS As New DataSet
Dim rowIndex As Integer = 0
Dim objConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=AccountDetails.accdb"
Dim objSqlStr As String = "SELECT * FROM qryAllDetails"
Dim objDA As New OleDb.OleDbDataAdapter(objSqlStr, objConn)
Public Sub FillDetails()
Dim objBalance As DataRow
objBalance = objDS.Tables("Balance").Rows.Find(txtBalance)
End Sub
Private Function Adder(ByVal intNum1 As Integer, ByVal intNum2 As Integer) As Integer
Dim answer As Integer
answer = intNum1 + intNum2
Return answer
End Function
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim intNum1 As Integer = txtBalance.Text
Dim intNum2 As Integer
Dim intresult As Integer
'assigns values
intNum1 = Val(txtBalance.Text)
intNum2 = Val(txtDeposit.Text)
intresult = Adder(intNum1, intNum2)
If intresult = 0 Then
MessageBox.Show("No value entered, Please re-enter lodgement amount") 'validates amount is entered
Else
MessageBox.Show("Your new balance is" & intresult)
End If
txtNewBalance.Text = intresult
End Sub
Private Sub Deposit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objDA.Fill(objDS)
Display() 'calls display
FillDetails()
End Sub
Private Sub Display()
'displays existing balance on screen when form loads
Dim intNum1 As Integer = txtBalance.Text
txtBalance.Text = intNum1
End Sub
Private Sub Retrieve()
'clears dataset of any existing values
objDS.Clear()
'fills dataset with info from dataadapter
objDA.Fill(objDS, "Balance")
End Sub
End Class
The GUI has 3 three text boxes, one containing the current balance, second contains amount to be added and the third displays the new balance. I am unsure of how to retrieve the current balance and save it again! Any help would be greatly appreciated!
I am getting an error on this line of code also
VB.NET:
Dim intNum1 As Integer = txtBalance.Text
Please help