DAO Querydefs
- From: "Mark" <mreed1975@xxxxxxxxxxxxxx>
- Date: Tue, 15 May 2007 19:42:52 +0100
Hi All,
what I am trying to achieve is rather than having loads of queries
stored within the database soley to use as a DAO recordset, I would like to
define the query within code. My problem is that a lot of these queries use
parameters and I do not know how to define these type of queries within
code.
My normal plan of attack would be to create and save the following SQL as a
query:
PARAMETERS lIORDOUID Long;
SELECT tbl_IORDOU.IORDOUID, tbl_IORDOU.IORDSTA, tbl_IORDOUL.Sku
FROM tbl_IORDOU INNER JOIN tbl_IORDOUL ON tbl_IORDOU.IORDOUID =
tbl_IORDOUL.IORDOUID
WHERE (((tbl_IORDOU.IORDOUID)=[lIORDOUID]));
I would then use the query as follows:
Set Qdef = CurrentDb.QueryDefs("Qry_NAME")
With Qdef
.Parameters(0) = SOME_PARAMETER
Set Rst = .OpenRecordset
End With
What I would like to do is something like:
Dim Qdef As DAO.QueryDef
Dim Rst As DAO.Recordset
Dim StrSQL As String
StrSQL = "PARAMETERS lIORDOUID Long; " & _
"SELECT tbl_IORDOU.IORDOUID, tbl_IORDOU.IORDSTA, tbl_IORDOUL.Sku " & _
"FROM tbl_IORDOU INNER JOIN tbl_IORDOUL ON tbl_IORDOU.IORDOUID =
tbl_IORDOUL.IORDOUID " & _
"WHERE (((tbl_IORDOU.IORDOUID)=[lIORDOUID]));"
Set Qdef = CurrentDb.QueryDefs(StrSQL)
With Qdef
.Parameters(0) = pIORDOUID
Set Rst = .OpenRecordset
End With
Could someone please tell me is this is possible and if so where I can find
some information?
Thanks in advance,
Mark
.
- Follow-Ups:
- Re: DAO Querydefs
- From: Rich P
- Re: DAO Querydefs
- Prev by Date: Re: Index
- Next by Date: Re: Index
- Previous by thread: Index
- Next by thread: Re: DAO Querydefs
- Index(es):
Relevant Pages
|