How would you return to a form after navigating to different form?

SCENARIO: I have 6 different forms. When I click a button on one of the forms, my macro ‘opens a different form’ and ‘closes the form’ that has the button.
Each form has a button’ to do what is described, plus a ‘BACK’ button, that works progressively (i.e. from FORM #6, back to FORM #5, then back to FORM #4, etc.). THE “STARTING” form is the ‘wildcard’ here — FORM #1 will always be different
Starting on FORM #1, I ‘click’ and go to FORM #5. From there, I ‘click’ and go to FORM #3. From here, I’d like to navigate back to my starting point, but I can’t seem to figure out how to ‘capture’ the form I started from into a variable.

QUESTION: Is there anyway to build a macro such that I can ‘capture’ the form I started from (FORM #1) and return to it, WITHOUT calling “getByName”?

Hello,

What is the reasoning or purpose of:

…return to it, WITHOUT calling “getByName”?

You can use loadComponent.
What method are you now using to go “BACK” to a previous form since that form is closed? And also to clarify, a starting form can be “FORM#3” or “FORM#5”, etc?

Although it probably does not affect this question, it is always best to include OS, specific LO version used and for Base the database being used (and connector if applicable).

Hi,
not sure if it helps, but I found a couple of macros some time ago which make formswitching a real breath,
its a small macro called toformFromForm, all the macro needs is info in the buttons general property like
frmGoto,frmClose.
Attached find an example
Hope its of use.
switchforms.odb

@gkick,

Thanks for the post. Think you may have missed in the original Q that after going to several different forms from a starting point of any of them, to be able to push a button to go back to this starting point.

You may want to add to your routine a check if the form exists. See my version in my answer here → Base ERROR - Open Form with macro

@Ratslinger, good point thanks, have to admit error handling is on my learning curve as there do not seem to be error numbers like in Access, thanks for the code

Hello,

There are a number of problems in dealing with your question. Initial reaction is to use a Global variable to store the initial form name. While you can set this when Base is first opened (checking there is no stored value already) it becomes useless if you start over with a different form without closing Base entirely (and possibly all open LO modules) and then restarting.

The one method I found to work is to use a hidden control on an internal form. This can be separate from your existing internal form(s). With Base started and a form opened the HiddenValue is empty and can be filled. Since each form can be a starting point, the same macro is attached to the OpenDocument event of each form. If the field already has a value no new value is moved in, otherwise it is the starting form name.

Each time a new form is called, before closing the old form, the value is transferred to the new form. And yes, ‘getByName’ is used to transfer the data. Don’t see any way around this and don’t yet understand why this seems to be a problem for you. Thus the current form always has the value of the originating form and can be used to call at any time. This will only change when all related forms are closed and a “new session” is started.

In the attached sample each form only contains buttons to call any of the other forms or the originating form. A message is displayed if you are already on that form. To make it easier to see the form you are viewing, a label is provided at the top of the form.

Edit:

Change Sample to add color to different forms ----- FormCall.odb

Edit 2020-02-06:

Original sample uses Firebird embedded DB. Here is a sample using HSQLDB embedded:

Sample ---- FormCall.odb

Thanks for the reply. Though I can’t RUN your sample FormCall.odb, I believe the macro code within holds the key to my issue. The use of a “hidden control” is exactly what is needed.
I am teasing it apart and adapting it to my needs, and will post as soon as I hammer out the details.
Thanks again.

Do not understand:

I can’t RUN your sample FormCall.odb

This has been tested as working - and yet again since I started this post (again downloaded & tested). You simply open any of the three forms and click buttons to see the operation. Why are you not able to run?

I am running OpenOffice 4.1.3 on a Mac running 10.10.5 (neither the “latest-or-greatest”, but strong and stable)

Clicking the forms to run throws a “the connection to the data source “form_call” could not be established” “the connection to the external data source could not be established. No sdbc driver was found for the given URL”

But, the macro code is proving very helpful / useful — it is helping illuminate the coding structure of how things get accomplished. I’m still in the process of applying the concept of what it is showing me so, NOT SOLVED yet.

Rest assured, you have very likely “answered” my (poorly worded) question by placing at my disposal pieces of the puzzle that were unclear, or missing, and I WILL post as soon as I work thru it. This is a hobby, of sorts, for me. I was/am an OLD VFP wannabe, but enjoyed the mental exercise of “building” something.

I STILL find it fascinating — imagine that. Thank you. And, I will POST again, asap.

@jrolland,

Please note that this is a site for LibreOffice users. Although we can try to help those using OpenOffice, those questions are better suited on another site → Apache OpenOffice.

You can’t run the sample because it uses a Firebird embedded database and is not supported in AOO.

Will now place one using HSQLDB embedded in the answer and you should be able to run that one (only tested in LO - do not have AOO currently installed).

Consider changing to LO.

Perhaps, now that I have solved my issue, I can do a better job of framing my question: My question was, “how can I navigate BACK to my ORIGINATING form from any other form I navigate to, without using GetByName?”

Using your response and sample you posted, I was inspired to explore the possibilities of those concepts. Subsequently, I SOLVED my issue using a “global variable” to capture the NAME of the form I was LEAVING, and pass it to another macro that I was using for navigation (a “switchboard-like” macro that works perfectly by accessing the “additional information” tab to OPEN a form, and CLOSE another). By INSERTING the value of my global variable into the “OPEN a form” portion of my navigation macro, I essentially gained the control I needed to navigate BACK to my ORIGINATING FORM programmatically — no matter WHICH form I started from. It works perfectly.

As to your suggestion(s), I have found that THIS site much more helpful, clearer, and more readable, than the site focused on OO — a testament to LO, and its users. I have on a number of occasions tried and WISHED I could move to LO, but it will not run on my hardware. The specifics of “why” escape me at present, but I finally gave up (can’t do any “work” if you spend your time trying to fix install issues).

My issue is SOLVED, thanks to your assistance once again. Now, if I could just figure out how to mark this as SOLVED, I would be finished for the moment.

What a MARVELOUS site…Thank you.

@jrolland,

You may want to read this → Ask/Getting Started

My apologies for breaking with protocol. Your advice and mastery has proven to be excellent and illuminating. Thank you. And, once again, apologies.