Try
' Takes a string from the textbox to find the records source in the database
Dim aid As String = ArrestIDToolStripTextBox.Text
Dim cmd As OleDbCommand = New OleDbCommand("SELECT SUM(AmountPaid) FROM tblPayment WHERE ArrestID ='" & aid & "'", con) ' SQL to pull the data from the database
con.Open() ' open the connection to the database
Dim amtpaid As Int32 = cmd.ExecuteScalar
TextBox2.Text = amtpaid
con.Close()
Dim x1, x2 As Integer
x1 = TextBox3.Text ' Total Fine amount.
x2 = TextBox2.Text ' Total amount Paid so far.
TextBox4.Text = Val(x1) - Val(x2) ' Subtracts the total fine amount from the amount paid to give us the total amount due.
Catch ex As Exception
MsgBox(ex.ToString)
End Try
|