H
Hugh N. Ross
I am using MS Access 2000 and trying to create a dynaset recordset. I have a
query that works properly in interactive mode. I have tried to put the
corresponding SQL into the vba code routine to open a recordset with the
query results. I get a compile error: invalid use of property. Following is
the first part of the subroutine.
Referance to any example articles would be appreciated.
Hugh N. Ross
Private Sub OKEmailBut_Click()
On Error GoTo Err_OKEmailBut_Click
Dim Mydb As DAO.Database
Dim SQLdef As QueryDef
Dim QryDat As DAO.Recordset, OutFile As DAO.Recordset
Dim frm As Form
Dim DatStr As String, LocalQtr As String, SQLString As String
Set Mydb = CurrentDb()
Set frm = Forms![frmInputE]
LocalQtr = frm.[txtQtr] ' This line works
' Open a recordset on the Members table
SQLString = "SELECT ([First Name] & ' ' & [Last Name] & ', ' & ) AS
Name FROM Members "
SQLString = SQLString & "WHERE ((([email]) Is Not Null)) And
(([Expiration] = [LocalQtr]))) "
SQLString = SQLString & "ORDER BY [Last Name]);"
QryDat = Mydb.OpenRecordset("SQLString") ' This line gives the compile
error
QryDat.MoveFirst
' etc
query that works properly in interactive mode. I have tried to put the
corresponding SQL into the vba code routine to open a recordset with the
query results. I get a compile error: invalid use of property. Following is
the first part of the subroutine.
Referance to any example articles would be appreciated.
Hugh N. Ross
Private Sub OKEmailBut_Click()
On Error GoTo Err_OKEmailBut_Click
Dim Mydb As DAO.Database
Dim SQLdef As QueryDef
Dim QryDat As DAO.Recordset, OutFile As DAO.Recordset
Dim frm As Form
Dim DatStr As String, LocalQtr As String, SQLString As String
Set Mydb = CurrentDb()
Set frm = Forms![frmInputE]
LocalQtr = frm.[txtQtr] ' This line works
' Open a recordset on the Members table
SQLString = "SELECT ([First Name] & ' ' & [Last Name] & ', ' & ) AS
Name FROM Members "
SQLString = SQLString & "WHERE ((([email]) Is Not Null)) And
(([Expiration] = [LocalQtr]))) "
SQLString = SQLString & "ORDER BY [Last Name]);"
QryDat = Mydb.OpenRecordset("SQLString") ' This line gives the compile
error
QryDat.MoveFirst
' etc