[Solved] List Box NULL selection

Creating and using forms
Post Reply
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

[Solved] List Box NULL selection

Post by DACM »

Okay, I've exhausted my knowledge of Base on this one.

Is there a way to eliminate the NULL selection option with OOo 3.3.0? All my own legacy and newly-created Forms now offer a NULL selection when using OOo 3.3.0 (but not when using OOo 3.1.1). Various .odb creations by others in the forum are hit or miss when opened with OOo 3.3.0. Some exhibit the NULL selection option, while others don't. There's no difference in the List Box or Form settings that I've found. So presuming that some of those downloaded .odb files were created with non-Windows platforms, I'm almost wondering if it's a Windows-specific .odb creation issue. In particular, Villeroy's modelmaker.odb exhibits both options in the same Form! One List Box has the NULL option while the other Table-Control List Box does not. BTW, my own stand-alone Forms DO NOT exhibit this issue; they don't offer the [undesirable] NULL selection option upon Save-As .odt.

Overall, I like the idea, and I certainly wouldn't mind such an option if I could turn it off/on in the Form design, but I can't seem to find such an option or even a workaround. Perhaps this a matter of making each Table-column 'NOT NULL' with SQL? Has anyone else seen this or found a solution? Is it simply a bug?

Here's what I'm seeing:
List Box function without NULL selection option under OOo 3.1.1 (Windows)
List Box function without NULL selection option under OOo 3.1.1 (Windows)
List Box function with NULL selection option under OOo 3.3.0 (Windows)
List Box function with NULL selection option under OOo 3.3.0 (Windows)
Karaoke.odb
This particular example includes macros, but I'm seeing this issue with/without macros involved.
(40.39 KiB) Downloaded 445 times
Last edited by DACM on Fri Mar 25, 2011 9:13 pm, edited 2 times in total.
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: List Box NULL selection

Post by Villeroy »

It used to be list box property "Input Required" on the data tab. But now it's another thing that stopped working in Base.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: List Box NULL selection

Post by DACM »

Here's the workaround I'm currently using:

Code: Select all

Sub WhenLoadingFormEvent (oEvent As Object)
   oEvent.Source.GetByName("List Box 1").RemoveItem(0)  'removes the List Box Null selection (overcomes OOo 3.3 bug)
End Sub
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: List Box NULL selection

Post by Villeroy »

It seems to me as if the null entry depends on the database field beeing nullable or not.
I loaded one of my embedded HSQLDBs http://user.services.openoffice.org/en/ ... p?id=10524
Removed the relation in the relation manager.
Made the forein key mandatory (not null, entry required=yes).
The form's list box misses the null entry.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: List Box NULL selection

Post by DACM »

Thanks for taking another look at this Villeroy, but this is beginning to confirm a Windows-build bug in OOo 3.3.0.

I still get the NULL option with your Form:
Windows 7 64-bit shows the NULL option unless I apply the above macro
Windows 7 64-bit shows the NULL option unless I apply the above macro
Macro applied to eliminate the NULL option
Macro applied to eliminate the NULL option
one_to_many (macro).odb
Added the macro which is evidently necessary with OOo 3.3.0 for Windows
(14.23 KiB) Downloaded 408 times
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: List Box NULL selection

Post by DACM »

Oh wait a minute...the "entry required = Yes" is set to "No" when opened in Windows.
So maybe that's the only bug if you're sure you set it to "Yes" before uploading the file.

I removed the Relationship, and changed entry required to "Yes", and replaced the relationship...
And it worked!

I'll have to test this further with my other Forms...but thank you!!!
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: List Box NULL selection

Post by DACM »

I think this is SOLVED!
Villeroy wrote:It used to be list box property "Input Required" on the data tab. But now it's another thing that stopped working in Base.
Correct. The following Form property no longer eliminates the NULL selection option in List Boxes, as it once did in OOo 3.1.1.
The List Box property "Input required" doesn't work
The List Box property "Input required" doesn't work
Villeroy wrote:Made the forein key mandatory (not null, entry required=yes).
That's it! :super:
The associated Table Field property is the solution
The associated Table Field property is the solution
So it's the Table Field property, not the Form List Box property that's the critical setting to avoid the NULL entry in List Boxes. I guess that makes some sense, but it probably should work either way. :D

Thanks Villeroy!
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Post Reply