Alter Query To Update TextBox

Hi!
Have a (Main) form for picking up a part (material). After having this working a sub-form will be linked to it of course.
Datasource of form = query SELECT pn, ad_data FROM Materials WHERE pn = [hard integer parameter set via code]
Form has:
• ListBbox for selecting the part, bound value NOT linked to table. Bound value is the parameter for modifying the query to select the desired pn.
• Button Ok to run the code.
• Textbox linked to column “ad_data” (additional data of the part).

So the Main Form shows:
[ name of the part ] as selected in the ListBox.
[ other data of the selected part ] in the TextBox.
Table Materials is to play “Filter Table”.

Problem: the query is correctly modified to add the <number = pn> from the ListBox.
But the TextBox (= ad_data column of the query) does not update. And the Refresh Button in the Navigation greys out showing the form was refreshed indeed (see below).
Only after closing and reopening the form is the data updated.
BUT if I do it manually putting a parameter (:p) in the query it runs ok. The form asks me 2 times for the parameter as it should be: on form opening and when running the routine.
Why the query doesn’t run after altered via code?
REM: Tried WAIT 1000 but to no avail.

Thanks in advance!




image

Why do you try to change the content of a query as command for a form?
I would change command for the form directly. Command of form should be SQL:

oForm.Command = sSQL
oForm.Reload

Remove qBaseForm as command from the form. Set SQL of this query directly and change the SQL.

Thank you!

Because I didn’t know this option.
I have experimented with updating a Filter Table in an analog way = ok.
Afterwards I wondered there should be no need for ANOTHER (the FT) table in the DB, and imagined setting up the source query based on the selection at ListBox.
Next step is of course clearing the ListBox + TextBox on Form opening.

By the way… what’s the difference between
Sql
Sql [Native]
?


Sql: Code could be created in query GUI and could be executed there without pressing “SQL” for direct SQL executing:
Sql [Native]: Code, which couldn’t be executed by query GUI. There are some functions GUI doesn’t know anything about.
Example

SELECT "Forename, "Surname" FROM "Table1"
UNION
SELECT "Forename, "Surname" FROM "Table2"

would show a combination of all persons in Table1 and Table2 - but could only be executed directly.
You couldn’t set a form with Sql [Native] as a form for changing data. It only could show the data - nothing else.