Page 1 of 1

[Solved] ListBox entry locks record

Posted: Mon Sep 05, 2011 1:28 pm
by David Lake
I have included a ListBox on a Form, but when I select anything from the list, the record locks and I can't move on to add another record.

Re: ListBox entry locks record

Posted: Mon Sep 05, 2011 1:47 pm
by Villeroy
You try to insert a duplicate into a field that is set up to not accept duplicates.
You try to insert a wrong data type or null where null is not allowed.

Normally you use list boxes to avoid all errors related to referencial integrity.
[Example] Relations reflected by list boxes in forms

Re: ListBox entry locks record

Posted: Wed Sep 07, 2011 11:11 am
by David Lake
Neither of these apply. The drop down is a foreign key field defined exactly as its related primary key. The correct values are displayed in the listbox, but the record locks.

Re: ListBox entry locks record

Posted: Wed Sep 07, 2011 11:40 am
by Villeroy
David Lake wrote:Neither of these apply. The drop down is a foreign key field defined exactly as its related primary key. The correct values are displayed in the listbox, but the record locks.
But the displayed value is not the foreign key value the listbox is going to write into the field. There is always a hidden second field behind the displayed ones.

This is how a list box can be fabricated to work with a visible field content and a foreign key:
Data Field: the table's foreign key
Input required: if nullable
Type of content: SQL
Content: SELECT "Visible_Field", "Other_Tables_PrimaryKey" FROM "Other_Table" ORDER BY "Visible_Field" ASC
Bound field: 1 [which is the 2nd field since #0 is the visible one. Yes, it's crazy]

Debug tip: Enter the same values you are trying to enter in the form directly into the underlying table or query respectively. Quite often this helps to understand why things go wrong.