Thank you.
But don't you think that open a recordset based on a SP is too expensive for
retrieving a single value ?
Is there any other solution? Opening, binding, reading and closing a
recordset does not waste time?
You told me to use Stored procedure. It's ok, but how can I pass the result
of a SP to my Vba code? I have always to open a recordset. Do I miss
something?
Bye
> You should use ADO Recordsets for this, or Stored procedures. DLookups are
> slow in this environment.
1) I use recordsets and/or stored procedures to get one value quite often.
It is very fast as you use the current connection. No mater how you get it,
the underlying activitiy will involve a recordset of some sort since that is
how Access is going to retreive a value.
2) I would consider an SP with an output parameter as it will run at the
server VERY fast. Here is a VBA function I use to get the current SQL user
by calling an SP.
Public Function GetUser() As String
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "GetCurrentUser"
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter("strCurrentUser", adVarChar,
adParamOutput, 20)
cmd.Parameters.Append prm
cmd.Execute
GetUser = cmd.Parameters("strCurrentUser")
Set prm = Nothing
Set cmd = Nothing
End Function
HTH,
Jim
> Thank you.
>
[quoted text clipped - 12 lines]
> are
> > slow in this environment.
Diego Lotti - 24 Dec 2004 07:36 GMT
Thank you very much!
I have no experience of adp and I feared that opening a recordset for
retrieve e single value was slow.
Now the point is clear: since I use the current project connection, the
execution of a SP or the binding of a recordset are very fast operations!
Thank you also for the output parameter info, I will use this approach when
I need a single value.
Bye
> 1) I use recordsets and/or stored procedures to get one value quite often.
> It is very fast as you use the current connection. No mater how you get it,
[quoted text clipped - 44 lines]
> > are
> > > slow in this environment.