Displaying a recordset in a datasheet view

clancypc

New member
Local time
Today, 20:20
Joined
May 3, 2012
Messages
1
Hi,
I have a procedure which generates a recordset in code. Currently I copy the recordset to a temporary table and use docmd.opentable to display the table. Is there a better way of doing it rather than creating the temporary table? Can I just display a recordset in a datasheet view?
Thanks
 
I don't believe you can. You can use your method or you may be able to use a continuous form and populate it with the recordset. Depends what you need to use the data for, if it's just for displaying then your method will work fine. If you then need to do anything with the data you may be better looking at a form approach.
 
You may just want to make an ubound form and on the OnOpen event set the recordsource of the form to the recordset in code. Then set the default view as datasheet. Quick and dirty. This would go in the OnOpen Event:

Dim strSQL As String
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb

strSQL = "Select CategoryID, Description From Categories"
Set rst = db.OpenRecordset(strSQL)
Me.RecordSource = strSQL
Me.txt1.ControlSource = "CategoryID"
Me.txt2.ControlSource = "Description"
 

Users who are viewing this thread

Back
Top Bottom