Temporary dynamic recordsets

jkirch

New member
Local time
Today, 10:16
Joined
Sep 18, 2002
Messages
6
For a report, I need to create a recordset that is not stored any place but can be edited. Has anyone come up with a way to do this?
 
Search for help on the DAO.Recordset Object

To create a dynamic recordset
Dim rst As DAO.Recordset, strSql As String

strSql = "Select tblName.fldName From tblName Where tblName.FieldName = yourParamterHere"

Set rst = CurrentDb.Openrecordset(strSql)

For a report you could set the Report.RecordSource = rst

Good Luck..
 
Though this is useful, and is what I have done in the past, I see that the recordset is still tied to 'TblName.' I was wondering if there was a way of getting around having the recordset tied to 'TblName' and still have it be able to get edited. Here is my Code.

Private Sub Bla()
On Error GoTo errhandle:
Dim qdef As DAO.QueryDef, rs As DAO.Recordset
Set qdef = CurrentDB.QueryDefs("TblName")
qdef!startday = "1/1/2002"
qdef!endday = "1/15/2002"
Set rs = qdef.OpenRecordset
'It is here that I need to initialize a recordset that can be edited but that does not alter any tables.
rs.Edit
rs!fieldname = "DATA"
.......


The only reason I want to do this is so that more than one person can use the report at a given time with different parameters (the "1/1/2002" would be an inputbox or something of the like). If you have any ideas on how to do this, they would be greatly appreciated.
 
Using the Sql String Method will have no permanent effect on your actual table. I would suggest you drop your Querydef method and use the Sql method instead.

Why would you edit a record when you have no intention of saving the edit?



If you simply want a mirror of the recordset then use..

Dim rsClone As DAO.Recordset
Set rsClone = rst.RecordsetClone

And then use the rsClone Object to populate your report.


I don't recommend this method. Sql is much more efficient
 

Users who are viewing this thread

Back
Top Bottom