Steve R.
Retired
- Local time
- Yesterday, 22:32
- Joined
- Jul 5, 2006
- Messages
- 5,741
Apparently I have a misconception on how to persist a recordset between subroutines when a form is opened. I have a project tracking database, the form in question only lists the the active projects. When the form opens, I have the following code which works:
However, when I add the line below to the Form_Activate subroutine, I get the error "Object Required". This leads me to believe that recordset is not available to the Form_Activate subroutine.
How would I keep the recordset open (available) for all subroutines attached to the form?
Code:
Public Sub Form_Open(Cancel As Integer)
Rem set initial parameters before opening form
formopened = True
Dim cdbs As dao.Database
Dim crst As dao.Recordset
Set cdbs = CurrentDb
Set crst = cdbs.OpenRecordset("select * from projectnumqry where [status]<10", dbOpenDynaset)
Set Me.Recordset = crst
Debug.Print "Number of Records01:"; crst.RecordCount
Call databasecolors
Call Form_Activate
End Sub
However, when I add the line below to the Form_Activate subroutine, I get the error "Object Required". This leads me to believe that recordset is not available to the Form_Activate subroutine.
Code:
Public Sub Form_Activate()
...
Debug.Print "Number of Records01:"; crst.RecordCount
...
End Sub
How would I keep the recordset open (available) for all subroutines attached to the form?