Base listbox - Table value for default selection

Hello,

I have a form with a listbox control that’s taking records from another table, using an SQL expression. So i can choose a record from another table that is connected with a primary key to the form’s own table.
It’s working ok when adding a new record, but how can i achieve that when i reading back the previously added record, the listbox has the referenced record from the other table as a listbox active item.
So the listbox should behave differently when adding a new item, and when i list a previously added record.

The SQL query for the listpanel:
SELECT "LocationID" || ' - ' || "Name" || ' - ' || "City" || ' - ' || "Country" || ' - ' || "Address", "Description" FROM "tbl_location"

Hello,
In the future please try to use correct terms. There is no such item as listpanel which you note in the title and four(4) more times in the text. Surprisingly you did note is correctly once as listbox. Also confusing in the title was the use of the wording data connection. Do not see how this relates to the question.


As for the question not knowing just how your form is set, if the internal form with the list box is Reset the new item should appear. You can (depending again on the structure) place a push button on that form with a Property on the General tab of Action set to Refresh Form:

Thank You for answering. Sorry i yet struggle with english, have no idea what compact title to give for this question. I’m open for suggestion but i understand that first i should describe my question more clearly. As for the listbox control, i have different language set for the GUI and did a literal translation.


tables


In general, the form reads data from table ‘storage’. When adding new records from this form to storage, i can select the storage's location from another table (location) using the listbox. That’s working ok (by me looking directy the table data), but later the previously added/connected location record should be ‘selected’ by default in the listbox for this storage record.

I see ‘Default selection’ at the listbox control’s general properties but cannot select or define anything here, only enter text freely.

@Kalman80
No need for apology. English is fine. Just need to use consistent terms.
.
Also appears I failed to realize what your actual problem was. Thank you for further clarification. With a list box, you can select one or two fields (more actually but not relevant). Your example has one (yes, multiple items but still one field). With a second field, you can display one item and store another. For example display your long string yet store just the ID. Then upon return, if the control is set correctly, the display will again translate for you. Also, you do not need to select/display all fields, just enough for you to recognized the wanted selection:

Here the SQL will display the first field selected (concatenated Name-City-Country) and the secont field selected is what is wanted to store in the record - LocationID. The field storec in the record is determined by the Bound field property. he relation to the select fields is zero (0) based. Therefore if you want the first field stores the Bound field is 0; if the second selected field then 1. When returning to this record, the translation will reverse for you.
.
Hope that makes sense.

Thank you. All is set as you described, creating the storage record is working fine. If i open the tbl_storage table manually, i can see the location selected from the listbox been saved at the storage record’s LocationID field. So creating the record is fine. However, the listbox does not select the location when reading the storage record back.

Have no idea what you have done exactly. Here is a sample with what I believe is your request →
ListBoxDemo.odb (13.3 KB)


If you still have a problem, post a redacted sample and further explanation.
.
Edit:
Have added a second form here as I am still not certain of what you want.
ListBoxDemo2.odb (23.2 KB)

All clear now, with your help the listbox working as i wanted. Problem was my misinterpretation about the SQL statement. Thank you for all your effort that been put into your answers! Much appreciated!