Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Nottingham, UK, Nottinghamshire, England
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MSHFlexGrid refresh (VB6)

    Has anyone a definitive answer as to how to get a MSHFlexGrid to refresh properly and show updated information? There's a lot of stuff about this returned from Google but no-one seems to have a real answer.

    I use a MSHFlexGrid to show a recordset in VB6 (so use Datasource set to a data environment, then the Datamember set to a simple 'SELECT * FROM documents ORDER BY a, b'; nothing fancy), and allow the user to click on any row which gets them into a separate screen where one option is to delete a record. This goes ok (I've set breakpoints and can verify that it does delete) but when I reactivate the form with the flex grid, the deleted record still shows, despite coding the following (in the form's Activate event):

    With de1.rstDocuments1
    If .State = adStateOpen Then .Close
    .Open
    .Requery
    .Close
    End With
    With flex1
    .Clear
    Set .DataSource = DataEnvironment1
    .DataMember = "tDocuments1"
    .Refresh
    End With

    I think the above is fairly clear; the actual names etc are correct. So I've closed and requeried the actual query, cleared and reset the grid, then used Refresh, but still to no avail! Does anyone have any idea what's wrong or missing or what? This also happens if I add a new record first then show the form with the flex grid - i.e. no new record shows!

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MSHFlexGrid refresh (VB6)

    I've only worked with this control in Access, not VB6, but I used a shaped recordset. I don't see why you would use an MSHFlexGrid to enter data. I haven't worked with it for several years, since I now work in VB.Net, but you might get more useful answers if you explain what you're trying to accomplish with this particular control.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Nottingham, UK, Nottinghamshire, England
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MSHFlexGrid refresh (VB6)

    Hi Charlotte - thanks for looking at this. I'm using the MSHFlexGrid (yes, the hierarchical one) simply because it's a quick and easy way to get an Access table shown in a VB6 application (tying it to a command in a data environment). I show the full table in a grid, then, when the user clicks on a row, use the Onclick method to show another form with that row's data and allowing either edits or a complete record delete, returning afterwards (after deletion or update) back to the form with the grid on it. It's the return to the first form that's the bugbear. No matter how I try (as with the quoted code before), I can't get the grid to show the updated results from the underlying query, either with the deleted record not showing or the updated record - and also (from a different way) a new record.

    The Refresh method on the grid (albeit with a rebind of the DataSource and restatement of the DataMember) is SUPPOSED to work, but it doesn't and there are murmurings on the internet to that effect but no answers! That's what I'm asking here - does anyone know of a definitive answer to this problem?

    Thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MSHFlexGrid refresh (VB6)

    OK, that's the way I used it in Access too. I found that I had to set the recordset to nothing and then recreate it before assigning it to the grid again. Don't know if it will help, but it shouldn't hurt. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Nottingham, UK, Nottinghamshire, England
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MSHFlexGrid refresh (VB6)

    I've tried that, Charlotte, but it made no difference. The statement 'Set de1.rstDocuments1 = Nothing' is invalid, though 'Set de1 = Nothing' is allowed - but apparently meaningless! Anyway, the act of rebinding the control to the data environment is *supposed* to be sufficient, but seems to make no difference. The crazy thing is that if you set breakpoints in the code and run it in the VB6 design environment, you can see the correct change in record count (up or down one if you add or delete records), but getting the MSHFlexGrid to refresh its data seems to be impossible - despite the Refresh method!

    Maybe the answer is simply that it (the Refresh method) just doesn't work after all. So frustrating! The user has to stop and restart the whole application to see the changes.

    Thanks for your input though - always good to have another pair of eyes on a problem.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MSHFlexGrid refresh (VB6)

    Sorry I couldn't be any more help. <img src=/S/disappointed.gif border=0 alt=disappointed width=15 height=15> I recall the control as being a very persnickety thing to work with, but I was using shaped recordsets, so I could set the recordset to nothing and then rebuild it in code. Good luck finding an answer. <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15>
    Charlotte

Posting Permissions

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