Groups | Blog | Home
all groups > sql server (alternate) > february 2004 >

sql server (alternate) : Pass record source parameters from an Access form to an Execute SP?


laurenquantrell NO[at]SPAM hotmail.com
2/12/2004 7:23:26 PM
I have a form myForm and it's populated by a Stored Procedure mySP.
This SP takes about a dozen parameters (the form displays the name and
employee ID as results of a contacts search with many criteria.) What
I want to do, after the contacts are displayed, is to be able to
create a string of e-mail addresses for those employees whose names
come up in the search.
I had this working fine when I had only two criteria, now I have a
dozen or so parameters and it doesn't work. Can someone point me to a
better way of doing this...
Any help is greatly appreciated.
LQ

This is what I was doing:

Dim RS As ADODB.Recordset
Dim mySP As String
Dim myIParam As String
Dim myID As Long
Dim myEList As String
Dim myETemp as String

mySP = Forms!myForm.RecordSource
myIParam = Forms!myForm.InputParameters

Set RS = CurrentProject.Connection.Execute("EXEC " & mySP & " " &
myIParam)
If Not RS.BOF And Not RS.EOF Then
Do While Not RS.EOF
myID = RS("employeeID")
myETemp = ExtractEMailAddress("SP2", myID,
"EMailAddress")
If Len(myEList) > 0 Then 'there is an email address:
myEList = myEList & myETemp & ";"
End If
RS.MoveNext
Loop
End If


Function ExtractEMailAddress(mySP as string, myID as long, myField
as string)
'I don't bother to include this code since all it does is looks
up the email address for the selected contact found in the above
code.

Erland Sommarskog
2/15/2004 7:28:31 PM
Lauren Quantrell (laurenquantrell@hotmail.com) writes:
[quoted text, click to view]

IF Len(myElist) > 0? Don't you mean Len(MyETemp)? With the above code, I
can't see myEList ever be assigned to.

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button