Page 1 of 1

[Solved] List Box NULL selection

Posted: Fri Feb 18, 2011 1:36 am
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 502 times

Re: List Box NULL selection

Posted: Fri Feb 18, 2011 2:56 am
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.

Re: List Box NULL selection

Posted: Fri Mar 25, 2011 5:23 pm
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

Re: List Box NULL selection

Posted: Fri Mar 25, 2011 7:29 pm
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.

Re: List Box NULL selection

Posted: Fri Mar 25, 2011 8:32 pm
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 483 times

Re: List Box NULL selection

Posted: Fri Mar 25, 2011 8:41 pm
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!!!

Re: List Box NULL selection

Posted: Fri Mar 25, 2011 9:12 pm
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!