I have an application with a routine that generates a recordset and then passes that to a report window. I would like to close the recordset when the report is closed, but I can't because I lose track of the recordset. How do I identify a distinct recordset so I can tie to a form so it can be closed later. Here's a simplified version of the code:
What I'd like to do is something along the lines of:Code:sub doReport() Dim myRecordset AS ADODB.RECORDSET Dim myReport as reportWindow SQLQuery = "SELECT * FROM myTable" DB.QUERY SQLQuery, myRecordset 'This populates my recordset Set myReport.Recordset = myRecordset myReport.show End sub
Hopefully that makes sense, I just don't know what to use to uniquely identify a recordset (like form.hwnd) in memory so I can refer back to it in the close routine.Code:private myRecordsets(10,10) sub doReport() Dim myRecordset AS ADODB.RECORDSET Dim myReport as reportWindow SQLQuery = "SELECT * FROM myTable" DB.QUERY SQLQuery, myRecordset 'This populates my recordset Set myReport.Recordset = myRecordset addReport myReport.hwnd, myRecordset.SOMEIDENTIFIER myReport.show End sub sub closeRecordset(formID) 'Finds the matching recordset for the given formID and closes it End sub sub addReport(formID, recordsetID) 'Add the formID and recordsetID to array End sub
Any suggestions?




Reply With Quote