Why does code work for one form, but not another?

I have code (copied below) that I use to reload a form, but it isn’t working for all forms and I can’t figure out why. Any thoughts? Thanks.

Sub FormReload(rReload)
Dim oForm as Object
Dim ObjName As String
ObjName = rReload
oForm = ThisComponent.Drawpage.Forms.getByName(ObjName)
oForm.Reload()
End Sub

SUB ReloadFrm_Add
FormReload(“Frm_Add”)
END SUB

It can only work, if all your forms are named “Frm_Add”, because there will be a call getbyname:

I have a separate SUB for each form, so it’s not that. I’m baffled. :confused:

Thought, this macro is just to work with Forms, not for SubForms.

That makes sense. Would there be a way to address both form and subform? Back to the drawing board lol

Which event should execute the macro? Event of a form or event of a control(button) inside a form?
For event of a form:

SUB FormReload(oEvent AS OBJECT)
   DIM oForm AS OBJECT
   oForm = oEvent.Source
   oForm.Reload
END SUB

For event of a control in a form:

SUB FormReload(oEvent AS OBJECT)
   DIM oForm AS OBJECT
   oForm = oEvent.Source.Model.Parent
   oForm.Reload
END SUB
1 Like

You are glorious!! I can already see how to apply this, thank you!! Let me play with this before I mark this as complete. Thank you again!!

This worked, thank you again. I’m don’t know how mark this as complete, but I’ll see what I can do. :grin: