CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Posts
    192

    MsgBox when textBox is changed

    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

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: MsgBox when textBox is changed

    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.

  3. #3
    Join Date
    Feb 2009
    Posts
    192

    Re: MsgBox when textBox is changed

    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

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: MsgBox when textBox is changed

    _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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured