ensurequry(tname,idfields,ids,reldef)

Build a query based on input or take it from the query string. All based on how the form is defined in the page.

Parameters:

- tname : table name

- idfields : fields defined by a relation to be used for the query (subform)

- ids : the values used by the fields in the generated query

- reldef : the relatation definitions given