Base Form macro not responding

I am writing a Database to catalog various picture that I have on my heard drive. I have made a form with various fields on it.

I have a listbox (lstbxBrtCtry) that is populated with country names using a sql select distinct statement that queries the worldcites table. The selected country is then put into the {birthCountry) textbox to the left of the list box.

I am trying to populate the (BirthCitylst} listbox based on which city is in the {birthCountry) textbox using a macro.

Here is the macro which I have attached to the (BirthCitylist) listbox when gaining focus event.

Sub pick_city_list
    Dim oForm as Object
    Dim countryText as string
    Dim cityList as Object
    Dim cityBox as Object
    Dim oCountryList as Object
    Dim oCountryBox as Object
REM Determine if the countrylist text box has a value
    oForm = ThisComponent.DrawPage.Forms.GetByName("dsPhotoInfo")
    oCountryBox = oForm.getByName("birthCountry")
    IF NOT IsNull(oCountryBox.text) THEN
End Sub

I am only using MSGBOXES becasue I read somewhere online that ThisComponent cannot be used with the BASICIDE debugger. I I am falling back to the oldest method of debugging and using MSGBOXES becasuse I could not locate a PRINT() function in Libreoffice BASIC.

The problem comes when I save the macro and the form then run the form and select the (BirthCitylist) listbox nothing happens neither message box get called.

can somone please tell me what I am doing worngly



Edited code for clarity.

Would not use:

IF NOT IsNull(oCountryBox.text) THEN


IF oCountryBox.text <> "" THEN

But that is not the entire problem as the code works for me.

Don’t know what DB you are using (tested with HSQLDB embedded - bad for embedded images). Don’t know what LO version you are using (tested with TDF v7.1.2.2) Don’t know what OS you are using (tested with Ubuntu 20.04).

A sample (attached to edited question) would help.

Also, you can use the IDE debugger. ThisComponent is only a problem when running the macro from the IDE itself. In this case, the macro is triggered from a form event. Just set your watches and break point.

I am using :

Version: (x64) / LibreOffice Community
Build ID: fe0b08f4af1bacafe4c7ecc87ce55bb426164676
CPU threads: 4; OS: Windows 10.0 Build 19041; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL
Using the HSQL database/

This is link to as zip file which contains the .odb file and a USER/ directory and 4 sub directories contain ONE graphic each. The graphic WILL NOT be embedded in the final database but linked so that I can move them around where I want to.

link text

I hope that is enouigh


In your question you stated:

The problem comes when I save the macro and the form then run the form and select the (BirthCitylist) listbox nothing happens neither message box get called.

but I see message box appearing when using the sample you posted.

Also see you have that macro tied to multiple controls.

It does not show up for me this is what I get when I just start the form in “run” mode. I use the term run mode for want of a better word.
link text

Here is the events dialog box for the BirthCountry listbox

link text

So you can see that no other event uses the pick_city_list macro


Only posting this because I need to display images. Your last links ask for me to sign into Google so no, I do not see. In fact here are three controls (as stated in my comment) all tied to the same macro:

And here is the message box on a form when the list box was selected (the other controls with the macro attached do the same):

Note that the message is incorrect as the code is incorrect. Noted this in my first comment.

Ratsinger First let me thank you for answering. and helping. Those two links should be open now. they had some default restriction from google that I did not notice. I just checked my version of the form on my machine here and none of those controls have anything associated with their focus event other than BirthCitylist

Ok correction I just looked at the form again and yes two other controls were attached to that same macro. I have now deleted those entries in the events dialog of each control and saved that form and the database
Saved the form and saved the database and shut down LibreOffice all together just to be sure. I restarted and checked this two other controls and the macros were gone. I got out of edit mode and “ran” the form and I clicked the down arrow on BirthCitylist and I get a blue highlighted text area and beneath that I which text area where I suppose the selections would normally appear.


Will give this some thought overnight. Have no clue as to your problem. Works for me with LO v7.1.2.2 (don’t see this as issue) and tested with both Ubuntu 20.04 and Win 10. Does loop in Win 10 as focus events for list boxes need close examination.

Also, again note that the Basic IDE can be used as I stated in my comment.

Final thought for today is try resetting you user profile. See → LibreOffice user profile


Have you tried resetting the User Profile as mentioned? I appears there is a new post with a similar problem. See → What might have caused macros to stop working.

Have you installed XRay? It is an Object Inspector.

[SOLVED] It was my fault. I had to lower the macro security level. There are now four levels. Previous version of LO just had a button to enable macros or not.