Hi,

Hello can you help me please how can i make a refresh button so that i will never close the program if there is update in the data to be made in other computer...

example if two computers or more..have installed the program and if one computer is making an update of the data example the last name of the employee.I will just click the refresh button...but the problem is i don't have idea how to do this refresh button so that i can see the changes of the data...is this possible?please help me...Thank you in advance and i'm hoping for your positive response...

If you are displaying in listview, just recall the code that you use when displaying the data.. This way the new update/changes will be visible..But make it sure that you clear the grid or listview first.

1. clear the control.
2. refresh the recordset from database.
3. populate the control.

Hello sir,

Sir Thank you for the reply, I am confuse of what you said sir..the clear the control,refresh the recordset,populate the control...can you please enlighten my mind sir..Thank you in advance and I'm Hoping for your positive response.

If you are displaying in listview, just recall the code that you use when displaying the data.. This way the new update/changes will be visible..But make it sure that you clear the grid or listview first.

Hello sir thank you for the reply...you mean that i am going to load again my code for displaying data into the grid in my refresh button?please help me sir ...Thank you in advance and i'm hoping for your positive response.

Example:

DataGrid1.DataSource = Nothing 'This will clear the data
Set DataGrid1.DataSource = MyRecSet1 'This will load the data
DataGrid1.Refresh 'This will display the data

lets see the code that you are working on.

Hello sir,


Okay i will get back as soon as possible...thanks for the patience.

public function loadrecord(optional byval filter as string)
'Your recordset query here
end function

And after the update of your recordset, recall this function to refresh your recorset..

loadrecord recfilter

You cal also use the .requery function of ADO.

Edited 5 Years Ago by blocker: n/a

lets see the code that you are working on.

Hello sir here is the code...sorry i'm late..Please correct me if i am wrong..

Private Sub cmdRefresh_Click()

lvwIP.ListItems.clear

lvwIP.Refresh

GetData lvwIP


End Sub


Private Sub GetData(LSV As listview)

Dim view As ListItem

 Set My_rs = New ADODB.Recordset
 My_rs.Open "SELECT * from Customer", con, adOpenStatic, adLockPessimistic
  
  
 LSV.ListItems.clear
 With My_rs
 txtname.Text = !User_Name
 txtfamily.Text = !Family_Name
 txtadd.Text = !I_Address
 If !vbYesNo = "Active" Then
   chkbox.Value = 1
  Else
     chkbox.Value = 0
  End If
  
     While Not My_rs.EOF
          
          Set view = LSV.ListItems.Add
          
          view.Text = !User_Name
          view.SmallIcon = "pc"
          view.SubItems(1) = !Family_Name
          view.SubItems(2) = !I_Address
          view.SubItems(3) = !vbYesNo
      
         My_rs.MoveNext
      Wend
  End With
      
    
  With lvwIP
    If .ListItems.Count > 0 Then
       Set .SelectedItem = .ListItems(1)
    End If
  End With
  
    
  
  My_rs.Close
End Sub

Give a try with below

Private Sub cmdRefresh_Click() 
lvwIP.ListItems.clear 
GetData lvwIP  
lvwIP.Refresh 
End Sub

Give a try with below

Private Sub cmdRefresh_Click() 
lvwIP.ListItems.clear 
GetData lvwIP  
lvwIP.Refresh 
End Sub

Hi sir, I aplogize i could not understand what you mean "give a try"...by the ways sir does my code in refresh button is okay sir?

Please try with the code which I posted and let me know. I have changed the order of the statement I.e refresh code will come after load the recordset

Give a try with below

Private Sub cmdRefresh_Click() 
lvwIP.ListItems.clear 
GetData lvwIP  
lvwIP.Refresh 
End Sub

Hello sir,

Sir i tried it and i don't see difference but it works...question sir.,is this the right order sir?Please help me thank you in advance and I am hoping for your positive response..

This question has already been answered. Start a new discussion instead.