Auto Populated Text Box Not Saving

My main question goes something like this (Ignore arrows):

Line up of items in image below:

  • MAINFORM
    List 1
    • SUBFORM
      List 2
  • MAINFORM 2
    Text 1
    Text 2
    Both Buttons

If I make a selection in “List 1”, it will populate “List 2”, and also enter the ID of the selected value of list 1 into Text 2. I then make an entry into Text 1. When I hit save, It should save text 1 as a title, along with text 2 as List1 ID, and also add a autofill ID of it’s own. But it doesn’t. It will save Text 1 with the autofill ID, but the List1 ID is blank.

If I change the Input Required under data to yes, it errors on save saying:

Input required in field ‘ID_List2_List1’. Please enter a value

Even though I can see the ID in Text 2. It doesn’t recognize that there is anything in Text 2, however I can see the number in it. How can I get the contents of Text 2 to save with the rest? I’ve tried saving it with the Save Record Action of the button, and I’ve tried with macro (Uno.RecSave, same code I use with other forms), but I get the same results with both. Input Required.

Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 7370d4be9e3cf6031a51beef54ff3bda878e3fac
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

A conundrum for your perusal. Let me know if you need other info. I’ve tried to cover my bases, but I’m sure I’ve probably missed something.

Thanks for your time :smiley:

  • First problem: Are there no tables or queries the forms are based on? Without tables data will not be saved.
  • If there are, would it be possible to include a screenshot of the table relationships, a stripped down odb sample, or more securely, the odb form as a Writer document? It is hard to tell what is going on without knowing what tables or queries, and types of data the form is based upon. Without these one would need to reverse engineer the form, usually resulting in something that is far from the creator’s initial intent.
  • However to get started, check that the textbox is actually assigned the correct data field in the control properties and that the data type in the underlying table matches what is being entered. While debugging, remove the input required property until the data saving problem is solved.

The data does save, just without Text 2.

Let me strip this down, and I’ll get you a sample.

This should be helpful. Don’t mind the mess of code :face_exhaling:

Lists and Txts.odb (37.3 KB)

Note: property Text of a form control is only what you see in the form, not what will be saved in the database. So Text could be changed and show other content than currentValue.
Working with boundField or oForm.getString(oForm.FindColumn(“Name in Datasource”) will get the value, which would be saved when pressing “save”.

That makes sense, and clears things up a bit more for me. Thank you.

OK, LODB really doesn’t like me. I downloaded that, and tried it. Same thing as before, Title, but no ID. I can see that you added something and it worked. TEACH ME YOUR MIGHTY WAYS OH GREAT ONE!

It also states on close that changes were made, and do I want to save. Even tho I hit save and directly hit exit. Nothing in between.

Oddly it is now not working on my end either… hmmm!
OK! This solution is going to support my preference of giving a control the exact same name as its data field. Changed textBox2 control name to “ID_Series_Author”. This then requires to find and replace all of the references to this textbox in all of the macro code. (Easy using the find (replace all) tool in the basic editor UI) Then modified some macros:

  • PopListSeries - Replaced the last two lines with these:

oTxtAuthor = oFrmSeriesAdd.columns.getByName(“ID_Series_Author”)
oTxtAuthor.value() = sSelectedValue

The “.columns” method refers directly to the “ID_Series_Aurthor” field in the underlying table, not just the control on the form. Here’s the updated sample odb! This is tweak of first “Lists and Txts” sample.
Lists_Txts_BestTweakYet.odb (37.1 KB)

That is sheer beauty and elegance!! I never would have thought of that haha Thank you thank you thank you!!