I have a small form to help me keep track of my expenses. The Expenses table has a relationship to the Categories table via CategoryID.
On my form the Categories listbox correctly displays the Category names but always writes 0 to the Expenses table.
If I write an INSERT query to write the data directly then everything works as expected. This leads me to think that the ListBox isn't representing the data correctly.
I have ListBoxes for Vendor and PayType also and they are exhibiting the same behavior.
Is there any way of viewing the INSERT statement being generated by the form? How do I debug this?
Thanks,
[Solved] ListBox writing incorrect IDs
[Solved] ListBox writing incorrect IDs
Last edited by EdSmelly on Sun Nov 19, 2017 1:11 am, edited 1 time in total.
OpenOffice 4.1.4 on MacOS 10.13
Re: ListBox writing incorrect IDs
Linked Field: CategoryID [the foreign key to be written]
Source Type: SQL [most flexible]
Source: SELECT "Name", "ID" FROM "Categories" ORDER BY "Name" ["Name" is the visible field, ID is the other table's primary key]
Bound Field: 1 [which is the second one, the visible one is 0]
Alternatively, save the SQL in a query
Source Type: Query
Source: query name
This is more handy if you need the same listbox in many forms.
Source Type: SQL [most flexible]
Source: SELECT "Name", "ID" FROM "Categories" ORDER BY "Name" ["Name" is the visible field, ID is the other table's primary key]
Bound Field: 1 [which is the second one, the visible one is 0]
Alternatively, save the SQL in a query
Source Type: Query
Source: query name
This is more handy if you need the same listbox in many forms.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: ListBox writing incorrect IDs
Yup, that was it alright. I used the wizard to design the form and when I added the ListBox I told it that I wanted the Category ID and the Category name and the statement it chose was SELECT "Name", "Name" FROM "Categories"... Also I don't recall seeing any reference to the Bound Field in the docs.Villeroy wrote:Linked Field: CategoryID [the foreign key to be written]
Source Type: SQL [most flexible]
Source: SELECT "Name", "ID" FROM "Categories" ORDER BY "Name" ["Name" is the visible field, ID is the other table's primary key]
Bound Field: 1 [which is the second one, the visible one is 0]
Thank you.
OpenOffice 4.1.4 on MacOS 10.13
Re: [SOLVED] ListBox writing incorrect IDs
Forget the form wizard. It does not even cover 10% of the possibilities. This forum has plenty tutorials and examples about proper form design.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice