i was just wondering, if you had a sub that creates object variables (such as recordsets), and in the middle of this sub you wanted to exit it, would it be a good idea to use a GoTo that jumps to the end of the sub that sets these object variables to Nothing, or is there a better way? eg:
VB Code:
Private Sub MySub() Dim rs As ADODB.Recordset Dim rs2 As ADODB.Recordset Set rs = New ADODB.Recordset Set rs2 = New ADODB.Recordset If ([i]some condition[/i]) Then If ([i]another condition[/i]) Then 'do something Else GoTo CleanUp End If Else 'do something else End If 'Do some more code CleanUp: Set rs = Nothing Set rs2 = Nothing End Sub
thanks![]()




Reply With Quote