Page 4 of 4

Re: [Base] Access2Base - Last version: 6.3

Posted: Sat Mar 11, 2023 12:49 pm
by JPL
The Value property is not applicable to Field objects belonging to a TableDef or a QueryDef.
At the opposite it makes sense for Field objects belonging to a Recordset.

An approach can be something like:

Code: Select all

Dim db, query, rs
     Set db = Application.CurrentDb()
     Set query = db.QueryDefs("SELECTTD")
     sSql = Replace(query.SQL, "?", CStr(_RACINE))     '  _RACINE is presumed a number	
     Set rs = db.OpenRecordset(sSql)
Another approach, if you are searching for 1 field or 1 expression is to use

Code: Select all

     db.DLookup(...)
The domain argument may be a query name.

Re: [Base] Access2Base - Last version: 6.3

Posted: Sun Mar 12, 2023 10:02 pm
by gelinp
Ok, thank you for your response. So I understand that if I've got 2 or more field to replace I can use 2 or more time the Replace function because the left most "?" will be replaced once a time...
But it's not as prepared query because in a prepared query there is a compilation and an optimization if I call more than one time the prepared query, even with different parameters. And with this solution it's like a first time with each different parameter, isn't it ?

Re: [Base] Access2Base - Last version: 6.3

Posted: Mon Mar 13, 2023 2:45 pm
by JPL
Indeed it is not like a prepared statement in terms of performance, as far as the RDBMS optimizes such statements.
But, functionally, there is no difference.

The Replace() function has a Count argument to manage the number of wanted substitutions (https://help.libreoffice.org/master/en- ... 2551162491).

JPL