Listbox Selected items does not show

Hello, I have a list box inside a form table inside the form named sales invoice and everytime I refresh the form the ones that i selected disappears and doesn’t show up.

Project.odb (455.1 KB)

When reloading the form all fields try to show the new selected values. But you have decided to create a listbox, which should only show a value one time and then this value should be removed from the listbox. So the listbox can’t show anything because the value you are looking for isn’t part of the query.

The only possibility to get it working is to create a listbox outside the tablecontrol, which will show the values inside the query and adds (per macro) the value of the current choosen row in the tablecontrol. The listbox in the tablecontrol could be set as a numeric field and has to be write protected.

Can you help me with the macro? I dont know how to make one and where to put in the events of the form. Im very new to this and dont know anything about programming

Have taken some old code. Will work but might be it could be solved a little bit better. Macro is linked to Form → Rowchange
Project.odb (455.7 KB)