A
Alex
I am trying to set the recordset of a form with and get a
message runtime message 3251 - the operation is not
supported by this object. Can you help?
This is my codes:
Sub cmdsearch_click()
Dim Db As DAO.Database
Dim qdfTemp As DAO.QueryDef
Dim qdfNew As DAO.QueryDef
Dim frm As Form
Set Db = CurrentDb
Set frm = Forms!ADDRESS
With Db
' Create temporary QueryDef.
Set qdfTemp = .CreateQueryDef("", "SELECT * FROM
tblADDRESS")
' Open Recordset and print report.
GetrstTemp qdfTemp
' Create permanent QueryDef.
End With
End Sub
Function GetrstTemp(qdfTemp As QueryDef)
Dim rstTemp As DAO.Recordset
Dim frm As Form
Set frm = Forms!ADDRESS
With frm
' Open Recordset from QueryDef.
.Recordset = qdfTemp.OpenRecordset
(DB_OPEN_SNAPSHOT)
With rstTemp
' Populate Recordset and print number of
records.
.MoveLast
MsgBox " Number of records = " & .RecordCount
End With
End With
End Function
message runtime message 3251 - the operation is not
supported by this object. Can you help?
This is my codes:
Sub cmdsearch_click()
Dim Db As DAO.Database
Dim qdfTemp As DAO.QueryDef
Dim qdfNew As DAO.QueryDef
Dim frm As Form
Set Db = CurrentDb
Set frm = Forms!ADDRESS
With Db
' Create temporary QueryDef.
Set qdfTemp = .CreateQueryDef("", "SELECT * FROM
tblADDRESS")
' Open Recordset and print report.
GetrstTemp qdfTemp
' Create permanent QueryDef.
End With
End Sub
Function GetrstTemp(qdfTemp As QueryDef)
Dim rstTemp As DAO.Recordset
Dim frm As Form
Set frm = Forms!ADDRESS
With frm
' Open Recordset from QueryDef.
.Recordset = qdfTemp.OpenRecordset
(DB_OPEN_SNAPSHOT)
With rstTemp
' Populate Recordset and print number of
records.
.MoveLast
MsgBox " Number of records = " & .RecordCount
End With
End With
End Function