How to Refresh 1 specific grid out of multiple grids

Good Day,

I have 3 grids, and I’m trying to make it so that I can refresh one specific grid without refreshing the other two. The one that I want to refresh is in the sub sub form. I have searched and searched, and cant figure out a way to do this. I have found a couple of ways to refresh all of them, but not the subsubform one.

MainForm - Grid 1

  • SubForm - Grid 2
    • SubSubForm - Grid 3

It’s Grid 3 that I want to reload/refresh, without affecting the other two.

I’ve learned that you can’t just reload the form that the grid is in, as that doesn’t reload the columns inside the grid, just the form that it is in. If you use a macro to save something from outside the grid (such as textbox’s and such), it will not show up in the grid until the columns within the grid have been refreshed. I know that you can create a separate button to refresh, but I’d rather use the extra code to add it to the save button.

Thanks

Grid 3 is refreshed every time you change the record in a parent form or when you hit a refresh button while the focus is in grid 3

You are correct, but it is very inconvenient to have to reselect the same options from Grid 1, then grid 2, just to add another record. This slows things down immensely when you have multiple records to add.

Why do you have to reselect? When editing the subform (or adding new records), the parent form stays at the same record. You don’t need to reload the parent because the child depends on the parent, but not the other way round.

Sorry, I meant that for if I use the reload code that refreshes all tables. If I don’t use that code,I can add new records to the grid, they just won’t show up. Again, I apologize for not explaining it better.

Why do you use “code”? Which code? What is the reason why new records don’t show up? Of course, they do show up on any normal (sub-)form without any “code”.

The latest code that I have found that refreshes all tables is:

Sub ReloadTable(sReload)
ObjName = sReload
Dim Forms : Forms = ThisComponent.DrawPage.Forms
Dim i%
For i = 0 To Forms.getCount()-1
Forms.getByIndex(i).reload()
Next
End Sub

I use code because I don’t like working within grid itself. The way I see it, if all you’re doing is using the grids, what’s the point of creating forms? May as well just use the tables and/or queries at that point lol.

relations2listboxes_FB.odb (73.0 KB)

Several forms reflecting a many-to-many relation between persons and tools and a one-to-many relation between persons and pets.

  • Each form shows all tables side-by-side, making it possible to edit all of them based on the relations between each other.
  • Each foreign key is represented by a listbox, so you can edit the foreign key by its associalted name.
  • Primary keys do not even appear on the form because they are just auto-IDs not relevant to the user.
  • Instead of a save button, why not use a Form ‘navigation bar’ control placed in subform 3 ( I prefer placing it over the top right corner of the grid). This bar has both the save and refresh buttons which do not use macros and are confined to only the subform where the bar is placed. Show or Hide different groups of buttons on the nav bar by changing its Control Properties (near the bottom of properties). You will want to Show the Acting on a record… group.
  • Also, if the subform 3 - Form Properties - Data - Cycle is set to Default or All Records, when the cursor (focus) advances past the last enabled field of the grids record (row), the subform and grid are saved and updated before advancing to the first enabled field of the next record. If the cycle is Active record, the cursor returns to the first enabled field of the current record without a save and refresh.

I haven’t done much with the Nav Bar, but I’ll look into it more closely. Currently, I have been trying to set it up so that the save button:
Saves the Record
Refreshes the Grid
Clears the text box
and error control
All with one click. I’m trying to make it as user friendly, and efficient as possible. What little I saw of the Nav Bar doesn’t do either of these. However, I’ll take a closer look at it.