• MSHFlexGrid refresh (VB6)

    Author
    Topic
    #437388

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #1039716

      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.

      • #1039746

        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.

        • #1039898

          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. shrug

          • #1039935

            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.

            • #1039982

              Sorry I couldn’t be any more help. disappointed 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. sorry

    Viewing 0 reply threads
    Reply To: MSHFlexGrid refresh (VB6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: