I just want to share what I have 're-discovered'... Its a disadvantage of 'loose' declaration of objects...
Case 1:VB Code:
Private Sub Command1_Click() Dim x As New ADODB.Recordset Set x = Nothing 'Will return false MsgBox x Is Nothing End Sub Private Sub Command2_Click() Dim x As ADODB.Recordset Set x = New ADODB.Recordset Set x = Nothing 'Will return true MsgBox x Is Nothing End Sub
Case 2:
VB Code:
'In Form1 Option Explicit Private Sub Command1_Click() Form2.ObjectsAreLoaded End Sub 'In Form2 Option Explicit Private adoRecordset1 As New ADODB.Recordset Private adoRecordset2 As ADODB.Recordset Public Sub ObjectsAreLoaded() 'Will return false = means object is instantiated MsgBox adoRecordset1 Is Nothing 'Will return true = means object is not yet instantiated MsgBox adoRecordset2 Is Nothing End Sub


Reply With Quote