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
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.
Re: Refresh another form on button Click
Just use Conn2 for the second one.
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.