Re: How to OpenRecordset(queryName refering to form)

Tech-Archive recommends: Fix windows errors by optimizing your registry



Though you are not painting the whole picture here, I suspect the problem is in the creation of the strSQL string, wherever you do that (the code that calls the function).
That code, should pass on to the function the *current values* of the form controls in the strSQL string, instead of references to the form controls, which I suspect is what you are trying to do.
Please post that part of your code, so I (or someone else) can provide more specific feedback. To that end, it will also help if you specify the data type of the fields to which each referenced control is bound (i.e. text vs. numeric vs. date etc).

HTH,
Nikos


Fjordur wrote:
Hi,
I have the following code
Public Function f(strSql As String, ...
...
r= CurrentDb.OpenRecordset(strSql)
I call f with the name of queries as arguments.

Calling function f with the name of a query works only when the query
doesn't include a where clause referring to an open form
([table].field=[Forms]![form]![control]).
Is there a way I can refer to the form in the query, so that I can use my
function f with only the name of the query as an argument? BTW some of the
queries have such a where clause, others don't.
This is rather crucial to the project, and I hope there's a way I can
circumvent this (hopefully a shortcoming of mine regarding SQL-VB syntax)
Thanx, all
.



Relevant Pages

  • Re: How to OpenRecordset(queryName refering to form)
    ... I don't create the query by code. ... form controls in the strSQL string, instead of references to the form ... can't imagine it's a problem of data type. ...
    (microsoft.public.access.queries)
  • Re: Union Query
    ... > How would I make these two Queries into an Union Query in a strSQL string? ... If the column EntryDate and the variables dtmMyStartDate and ...
    (microsoft.public.access.queries)