Click to See Complete Forum and Search --> : MsgBox when textBox is changed


dr223
April 8th, 2009, 10:09 AM
Hallo,

I have the following save function shown below, when called some tables get updated. Before fields are updated specifically to TblOracleNos what I want to do is when the text in TxtOracleNo has been changed and the save function called a MsgBox pops saying "Oracle number has been changed".

Any ideas ... Thanks


Public Sub Save()

Dim conn As SqlConnection = GetDbConnection()
Dim query As String
Dim cmd As New SqlCommand

If TxtNumPats.Text >= "1" Then

Try

query = "UPDATE gprdsql.TblPracDetails SET pay_acc_num ='" & _
TxtAccount.Text & "' where Prac_No='" & _
TxtPracNo.Text & "'"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()

query = "UPDATE gprdsql.TblPracDetails SET pay_sort_code ='" & _
TxtSort.Text & "' where Prac_No='" & _
TxtPracNo.Text & "'"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()

query = "UPDATE gprdsql.TblPracDetails SET payee_name ='" & _
TxtPayee.Text & "' where Prac_No='" & _
TxtPracNo.Text & "'"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()

query = "UPDATE gprdsql.TblOracleNos SET Oracle_no ='" & _
TxtOracleNo.Text & "' where Prac_No='" & _
TxtPracNo.Text & "' and Prac_eid = '" & _
TxtPracEid.Text & "' and Pay_method = '" & _
CmbPayMethod.Text & "'"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()


Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "GCPM")
End Try

DataMiser
April 8th, 2009, 11:01 AM
Well one of many things you could do would be to set the tag of your textbox=the text of your textbox before the record is edited and then in the save function compare the tag to the text and if they are different display your message box.

dr223
April 9th, 2009, 05:01 AM
Please can anyone tell me whats wrong with this code;

When I try to enter this line of code it gives me an error ;


Private Sub TxtOracleNo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtOracleNo.TextChanged

_txtOracleNoDirty As Boolean
_txtOracleNoDirty = True

End Sub


I have a TxtOracleNo textbox, which is populated by an oracle number when the form is loaded.
What I want to do is, when the oracle number is changed a message box is prompted to inform the user that "oracle number changed".

Therefore, I was trying to use the dirty property on TxtOrcaleNo_TextChanged event.

Then when the Save button is clicked; Insert the following code

If _txtOracleNoDirty Then

MsgBox("Oracle Number Changed")

End If

'Reset the variable again to false
_txtOracleNoDirty = False

Any help please!!!

Thanks

DataMiser
April 9th, 2009, 09:52 AM
_txtOracleNoDirty As Boolean
_txtOracleNoDirty = True

Looks like you are trying to dim a property here on the first line [Guessing]
This is not correct.

Second line looks like you are trying to access a property also not correct.

To access a property of a control you provide the controlname.PropertyName


Why did you not just use the tag property like I suggested?