Open form via macro in Libreoffice Base

Hi I’m trying to make my database user friendly and I have a question:

From one form, A, I’m launching another form, B, using a button with this macro attached:

Sub openFormByTag(oEv)
	cWhat =
	oModel = oEv.Source.getModel()
	sName = oModel.Tag
	oView = oModel.Parent.Parent.Parent.Parent.getCurrentController()
	oView.loadComponent(cWhat, sName, FALSE)
End Sub

Works fine, but: I would like to specify a row id or something in form A so that form B scrolls automatically to the the particular row I want to view or edit.

Doe anyone have an idea about how this can be done?

Or maybe where there are some comprehensible documentation for this kind of issue perhaps?

Thanks in advance.

The cleanest way to explore functions and methods in LO Basic is to identify the object in question and then execute:

MsgBox target_object.dbg_properties
MsgBox target_object.dbg_methods

The best API reference is here but it is not so user-friendly.

For the functional question, I have found most useful an alternative syntax, which refers to the form root and controller::

root_doc = ThisComponent
form_container = root_doc.Drawpage.Forms
form_ctrlr = root_doc.getCurrentController()
main_form = form_container.getByName("MainForm")

For opening a form, I have seen this, which appears to get to the same place:

form_container = ThisDatabaseDocument.FormDocuments.getByName("Form1")
main_form = frm_container.component.getDrawPage.getforms.getbyindex(0)

Functions for moving to different rows in the record source are, among others (look at .dbg_methods):

You could use those commands and test the values of controls on your form as you go.

A better way would to filter the contents of the form. Of course, there would be a limited recordset visible, but it would be fast and clean:

main_frm.Filter = " ""frmB_col"" = 'frmA_data'"

Old question, but popular, hope this helps.

Can you explain line by line what is going on?

Well, partly. I am a progammer, but have no experience in Basic and the libre/openoffice API frameworks.
I got the code from another post somewhere. The name of the form to open is stored in the tag member of the calling button. That way I can reuse the routine to launch other forms.
Why do you ask? Do you know about a solution?

UPDATE, while @Doug’s answer is valid, I think the MRI introspection tool provides a much better, quicker and more interactive way to see what’s going on.