Not Me <No***********@here.com> wrote in
news:ci**********@ucsnew1.ncl.ac.uk:
Hey,
Coming back to a piece of work I did a while back, which used a stored
procedure to populate a list box. The SP takes a single parameter,
and I think this is the reasoning for using 'exec' in the row source
(I assume you need this for parameters?)
The problem is this only works when I access the form.. If I do it
from someone else's computer they get a blank listbox. They have
appropriate permissions for the stored procedure, so is the 'exec'
getting in the way?
Can I use a parameterised sp in a row source for a listbox without
using exec? or is there a way of sorting it that the user can use the
stored procedure? (there's no error messages to say there's no access)
The stored procedure was created using my login, not dbo (if that
makes a difference)
Thanks for any help you can give!
Chris
Recently I have resorted to using a string as follows:
***************************************
lstTeachers.RowSourceType is Value List.
Form_open Code is:
Private Sub Form_Open(Cancel As Integer)
Dim r As ADODB.Recordset
Dim TSQL As String
If SysCmd(acSysCmdGetObjectState, acForm, "frmAssignTeachers") And
acObjStateOpen = acObjStateOpen Then
TSQL = "SELECT 0 AS fldTeacherID, NULL AS fldTeacherName" _
& vbNewLine & "UNION" & vbNewLine & _
"SELECT fldTeacherID, fldTeacherName FROM tblTeachers
WHERE fldSchoolID = " & Form_frmAssignTeachers.txtSchoolID.Value & "
ORDER BY fldTeacherName"
With Me
.lstTeachers.RowSource = CurrentProject.Connection.Execute
(TSQL).GetString(, , ",", ",")
.InsideHeight = Form_frmAssignTeachers.InsideHeight
End With
PlaceForm Me
End If
End Sub
*******
In the code there are procedures extraneous to the question at hand, of
course. As ever, line breaks introduced by news clients can make code
unusable without editing.
There does not seem to be any noticeable time penalty for this way of
doing things. As far as I know, it is the only way to use the equivalent
of parameterized stored procedures with Application Role MS-SQL
permissions and ADPs.