hi all,

I have a performance question.

Sometimes I write a function that returns an object, but I don't always call it and use the returned object, what really happens here?

Example:
VB Code:
  1. Public Function ExecuteSQL (ByVal sSQL As String) As Recordset
  2.     Set ExecuteSQL = myConn.Execute (sSQL)
  3. End Sub
Sometime I call it as follows.
VB Code:
  1. Dim rsTemp as Recordset
  2. Set rsTemp = ExecuteSQL ("Select * From Table1")
In the above call, the function ExecuteSQL creates an instance of a Recordset in the calling function scope, then puts a pointer to that object in rsTemp, am I right?

Now, what happens if I just call it like this:
VB Code:
  1. ExecuteSQL("Insert Into Table1 (Field1, Field2, Field3) Values (""TestField1"", ""TestField2"", ""TestField3"")")

will the ExecuteSQL function still create an instance of a Recordset in the calling function scope? If so, is it better to create to versions of that function, one a Function and the other a Sub?