Results 1 to 18 of 18

Thread: [RESOLVED] how to refresh the listview with another form

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] how to refresh the listview with another form

    hello
    i have a listview and in trying to refresh it by showing another form that says
    refreshing list please wait
    tnx for the help
    this is the code that call the refresh
    Code:
    Case 11: If LsVw.SelectedItem Is Nothing Then Exit Sub
            loadentries
    and the code for the refresh
    Code:
      Sub LoadEntries()
    
    LsVw.ListItems.Clear
    TxtFind.Text = ""
    FrmCusts.MousePointer = vbHourglass
    
       Set RS = CN.Execute("SELECT * FROM Customers ORDER BY FullName ")
         
        
      TxtFind.Enabled = False
      TlBar.Enabled = False
      
       
        While Not RS.EOF
            Set Itm = LsVw.ListItems.Add(, , RS!FullName, , "cust")
            Itm.Tag = RS!ID
            Itm.Bold = True
            Itm.SubItems(1) = RS!Address
            Itm.SubItems(2) = Format(RS!DateBirth, "dd/mm/yyyy")
            Itm.SubItems(3) = RS!Facebook
            Itm.SubItems(4) = RS!Email
            Itm.SubItems(5) = RS!Phone
            Itm.SubItems(6) = RS!Cellular
            Itm.SubItems(7) = RS!HairColour
            Itm.SubItems(8) = RS!Oxygen
            RS.MoveNext
            DoEvents
            Wend
           
             FrmCusts.MousePointer = vbNormal
            
          TxtFind.Enabled = True
            TlBar.Enabled = True
         
         
    End Sub
    tnx for the help

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how to refresh the listview with another form

    If you are using VB6 just make the sub public and call the LoadEntries() sub from the other form or put the code in a module and do the same thing.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    im using vb 6

    can you give me an example?

  4. #4
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: how to refresh the listview with another form

    Code:
     Sub LoadEntries()
     label1.caption = "Refreshing Please Wait.....
    LsVw.ListItems.Clear
    TxtFind.Text = ""
    FrmCusts.MousePointer = vbHourglass
    
       Set RS = CN.Execute("SELECT * FROM Customers ORDER BY FullName ")
         
        
      TxtFind.Enabled = False
      TlBar.Enabled = False
      
       
        While Not RS.EOF
            Set Itm = LsVw.ListItems.Add(, , RS!FullName, , "cust")
            Itm.Tag = RS!ID
            Itm.Bold = True
            Itm.SubItems(1) = RS!Address
            Itm.SubItems(2) = Format(RS!DateBirth, "dd/mm/yyyy")
            Itm.SubItems(3) = RS!Facebook
            Itm.SubItems(4) = RS!Email
            Itm.SubItems(5) = RS!Phone
            Itm.SubItems(6) = RS!Cellular
            Itm.SubItems(7) = RS!HairColour
            Itm.SubItems(8) = RS!Oxygen
            RS.MoveNext
            DoEvents
            Wend
          pause 2
    label1.caption = "Loading Finished"
             FrmCusts.MousePointer = vbNormal
            
          TxtFind.Enabled = True
            TlBar.Enabled = True
         
         
    End Sub

    Sub Pause(interval)
    Dim atime
    atime = Timer
    Do While Timer - atime < Val(interval)
    DoEvents
    Loop
    End Sub

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    what is this?
    Code:
    Sub Pause(interval)
    Dim atime
    atime = Timer
    Do While Timer - atime < Val(interval)
    DoEvents
    Loop
    End Sub

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: how to refresh the listview with another form

    I would not use that pause sub. Should be avoided at all costs

    You could as mentioned before make the sub public and call it from the other form
    Code:
    Public Sub LoadEntries()
    Code:
    Fomr1.LoadEntries
    Or you could show the second form and refresh it at the top of the sub routine
    Code:
     Sub LoadEntries()
          Form2.Show
          Form2.Visible=true   'may not be needed
          form2.refresh   ' may not be needed   ... these lines added only to insure that the form is actually displayed before the code continues on.

  7. #7

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    hey DM
    the thing is that i already created another form
    and i have a toolbar
    that calls this procedure
    Code:
    Case 11: If LsVw.SelectedItem Is Nothing Then Exit Sub
            here i did form1.show 1
    i want the form1 to be displayed wile the backround with the listview gets refreshed

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: how to refresh the listview with another form

    If you are using the modal flag then you would have to call the sub from that form.

  9. #9

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    and how do i do that?

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: how to refresh the listview with another form

    Like I showed you in the earlier post you make the sub public and call it from the other form using formname.subname

  11. #11

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    i tried that didnt work
    i just want a form to show loading wile in the backround the listview gets refreshed and when it finishes the the form loading dissapears

  12. #12
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: how to refresh the listview with another form

    check post 4 why are u making things hard for u ?

    start with simple code the pause code to your project and rest code try it
    then later on when u se results just remove the lables and use forms instead

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: how to refresh the listview with another form

    Quote Originally Posted by salsa31 View Post
    i tried that didnt work
    i just want a form to show loading wile in the backround the listview gets refreshed and when it finishes the the form loading dissapears
    Show the code that you are actually using now and be more descriptive when you have a problem saying it didn't work does not tell us what went wrong
    The method I showed you will work if you do it correctly. You can also place the code that loads the list on the other form in a public sub and call it from the first form

    Code in your second form
    Code:
    Public Sub LoadList(TheList as ListView)
        Me. Visible=true
        Me.Refresh
        ' code to populate TheList
       Unload Me
    End Sub

  14. #14

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    this is the code when i press refresh in the form 1
    Code:
      Sub LoadEntries()
    
    LsVw.ListItems.Clear
    TxtFind.Text = ""
    FrmCusts.MousePointer = vbHourglass
    
       Set RS = CN.Execute("SELECT * FROM Customers ORDER BY FullName ")
         
        
      TxtFind.Enabled = False
      TlBar.Enabled = False
      
       
        While Not RS.EOF
            Set Itm = LsVw.ListItems.Add(, , RS!FullName, , "cust")
            Itm.Tag = RS!ID
            Itm.Bold = True
            Itm.SubItems(1) = RS!Address
            Itm.SubItems(2) = Format(RS!DateBirth, "dd/mm/yyyy")
            Itm.SubItems(3) = RS!Facebook
            Itm.SubItems(4) = RS!Email
            Itm.SubItems(5) = RS!Phone
            Itm.SubItems(6) = RS!Cellular
            Itm.SubItems(7) = RS!HairColour
            Itm.SubItems(8) = RS!Oxygen
            RS.MoveNext
            DoEvents
            Wend
           
             FrmCusts.MousePointer = vbNormal
            
          TxtFind.Enabled = True
            TlBar.Enabled = True
         
         
    End Sub

  15. #15

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    Code:
    Public Sub LoadList(TheList as ListView)
        Me. Visible=true
        Me.Refresh
        ' code to populate TheList
       Unload Me
    End Sub
    where do i put this?

  16. #16
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how to refresh the listview with another form

    Personally I don't care for forms that load data in other forms like this... having a "please wait" form is fine... but that's all it should do... it should be generic and do nothing more.... the form that the listview is on is what should be responsible for loading the listview.

    Just my two cents.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  17. #17
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: how to refresh the listview with another form

    bump i bet this simple thread will go past 30 post bump

  18. #18

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to refresh the listview with another form

    tnx all for the help
    i just did frame1.caption loading...

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