Base - Image Button Refresh for Subform Table - How?

Hello community, my first post here.

I am currently finishing a database and am at the very last part, where I am using an Image Button to refresh the table data on a subform being used. When I choose ‘Action’ - Refresh Form, well, it appears the Dev’s never implemented this feature, because it does NOTHING. Basically, I need an Image Button to act the same as a typical Push Button with ‘Action’ - Refresh Form. How can I accomplish this? I am guessing macro magic, or is there some trick I am missing to make an Image Button actually use the assigned Actions in properties?

The button has to specifically only refresh the subform table and cannot be the included refresh for the record entirety. I am not much of a coder, so looking for a bit of help with a macro to accomplish this.

Thanks peoples.

-Nixx

Hello,

There has been an open bug report on this for some time - tdf#46579

You can reload the form the button is on with this macro:

Sub ReloadForm(oEvent)
  oEvent.Source.Model.Parent.reload()
End Sub

Tested by attaching to Mouse button pressed event.

Focus needs to be on the sub form to be reloaded when executing this.

Edit:

If needed you can set the Image Button pressed with the focus before the reload:

Option Explicit
Sub ReloadForm(oEvent)
    Dim oField   As Object
    Dim oDocCtl   As Object
    Dim oCtlView   As Object
	oField = oEvent.Source.Model
	oDocCtl = ThisComponent.getCurrentController()
  	oCtlView = oDocCtl.GetControl(oField)
	oCtlView.setFocus()
    Wait 100
    oEvent.Source.Model.Parent.reload()
End Sub

Yes, that is exactly what I was looking for. Thank you very much Ratslinger.

The first one I would find annoying after awhile, but both work perfectly and as you described. I chose to go with that second method. Works very well.

Option Explicit
Sub ReloadForm(oEvent)
    Dim oField   As Object
    Dim oDocCtl   As Object
    Dim oCtlView   As Object
    oField = oEvent.Source.Model
    oDocCtl = ThisComponent.getCurrentController()
    oCtlView = oDocCtl.GetControl(oField)
    oCtlView.setFocus()
    Wait 100
    oEvent.Source.Model.Parent.reload()
End Sub

Now, if only that gets fixed one day so it works as you think it would so a macro like this would not be needed. ^-^

Thanks again.