OpenRecordset(queryName) refering to form

  • Thread starter Thread starter Fjordur
  • Start date Start date
F

Fjordur

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
(
.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
 
Fjordur said:
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
(
.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


I think part of your problem may not be that the where clause is
included, but that the form isn't open when you try and set the recordset.

I'm not sure if you copy/pasted or typed in pseudo code, but this line:
r= CurrentDb.OpenRecordset(strSql)
should be:
set r= CurrentDb.OpenRecordset(strSql)
 
Fjordur said:
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
(
.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


I didn't realize that you had already reposted this question in another
thread. I'm going to kill this discussion and let the other one continue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top