Close Form Throwing an error - FIXED

Aaaaaaargh! IGNORE ME!!! I had the same code linked to a close form event and a button event!!! Works fine!!!

Libre Office
Version: 6.4.7.2
Build ID: 1:6.4.7-0ubuntu0.20.04.1
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3;
Locale: en-AU (en_AU.UTF-8); UI-Language: en-US
Calc: threaded

Database: HSQLDB Embedded

ERROR MESSAGE:

BASIC Runtime error.
An exception occurred
Type: com.sun.star.lang.WrappedTargetException
Message:
Target Exception:
Type: com.sun.star.embed.StateChangeInProgressException
Message:.

This error occurs when I issue a close event in a Macro
the line in question
sTitle = ThisComponent.Title ’ works
iStart = Instr(sTitle,":") + 2 ’ works
sName = Mid(sTitle, iStart) ’ works

ThisDatabaseDocument.FormDocuments.getbyname( sName ).close ’ fails with the above error

I have tried variants as listed below :
oForm1 = ThisComponent.DrawPage.Forms.getByIndex(0) ’ refers to the current form

oForm1.parent.parent.CurrentController.Frame.close(true)
thisComponent.CurrentController.Frame.close(true)
ThisDatabaseDocument.FormDocuments.getbyname(oForm1).close
oForm1.close(true)

What might I be missing. Sadly the database is too large to post

All I do is use a macro to close my main form and open another. Works well
closing the subsequent form using a button event which opens the main form and closes the subsequent form fall over. oForm refers to the main form and oForm1 refers to the form in question so that there is no conflict of variables.