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

    Refresh another form on button Click

    Hallo,

    I have a form called FrmPracDetails which is built up with a List view called LvwColProc.

    Therefore when you click a field on the LvwColProc it takes you to another form called FrmColProcessing, here you can make changes to certain fields which are also present on FrmPracDetails.

    What I want to do is when you make changes on FrmColProcesing and Click the Save Button (which calls the Save function)the changes appear instantly on FrmPracDetails.

    Please note, FrmColProcessing will always be open next to FrmPracDetails.

    I have tried to put this code in the Save function present in FrmColProcessing as shown below, but it doesnt Refresh FrmPracDetails form.

    Any ideas please, thanks



    Code:
    Private Sub Save()
    
            Dim conn As SqlConnection = GetDbConnection()
            Dim query As String
            Dim cmd As New SqlCommand
    
            Try
    
                query = "UPDATE gprdsql.TblCollections SET Additional_info ='" & _
                               TxtAddInfo.Text & "' where col_uid='" & _
                               TextBox3.Text & "'"
                cmd = New SqlCommand(query, conn)
                cmd.ExecuteNonQuery()
    
                query = "UPDATE gprdsql.TblCollections SET stage ='" & _
                              CboColStage.Text & "' where col_uid='" & _
                              TextBox3.Text & "'"
                cmd = New SqlCommand(query, conn)
                cmd.ExecuteNonQuery()
    
    
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Information, "GCPM")
            End Try
    
            MsgBox("Details have been updated", MsgBoxStyle.Information, "GCPM")
    
            FrmPracDetails.LvwColProc.Refresh()
    
    
        End Sub
    Last edited by HanneSThEGreaT; August 11th, 2009 at 08:16 AM. Reason: Code Tags!

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Refresh another form on button Click

    I'm not a Database Guru

    I would suggest that you close the connection on FrmPracDetails, then re open it. The data that is displayed in FrmPracDetails, is already cached, so, that needs to be reloaded.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Refresh another form on button Click

    Just use Conn2 for the second one.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

    Re: Refresh another form on button Click

    How is the listview being built? All I see in the code is a line to refresh the list view which very likely does nothing at all as it would refresh anyway as soon as your sub exits. If you built the listview through code then you would need to have a routine to rebuild it or at least to modify the selected item. refresh basically just redraws it.

    Or are you trying to refresh the data int he fields on the form? If so how are the field populated, are they bound? Are they populated via code. In any case refreshing the list view will have no effect.
    Last edited by DataMiser; August 13th, 2009 at 08:53 AM.

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