Hello,
I have a form collection that is looking up information from a SQL view. The SQL view is sorting by District, School, then Last Name. When I run the form, the collection is not sorting. Any suggestions?
Thanks!
Question
Question
Sorting Form Lookup
Replies
Hi Tiffany
If you are using the Forms Table Lookup, then you can only choose the sort order where you configured the lookup
If you were using a Stored Procedure then the data would be returned in the order determined by the SQL Stored Procedure programming
Thank you!
Stored procedures are new to me. I have this for my view.
SELECT TOP (100) PERCENT [Active OT], [Serving District], School, [Last Name], FY, [OT Full Name], [COTA Full Name], StudentNIAID, [First Name], [Date of Birth], [Grade New], [OT Direct Min],
[OT Direct Min Per], [OT Consult Min], [OT Consult Min Per]
FROM dbo.[dbo_tbl-Therapy Services SQL Update]
WHERE ([Active OT] = 1)
ORDER BY [Serving District], School, [Last Name]
I'm trying to create a stored procedure
CREATE Procedure AllOTStudents
AS
Select *From [dbo_tbl-Therapy Services SQL Update]
WHERE ([Active OT] = 1)
ORDER BY [Serving District], School, [Last Name]
Go
And to execute, I have this.
Execute AllOTStudents Go
I get the query to run, but it is not sorted. Do you know what I'm missing?
Thanks!
I got the Create Procedure and Execute queries to run. I think I might be missing parameters. I need the collection to populate the students that are assigned to each therapist/assistant combination.
CREATE Procedure AllActiveOTStudentsEOY1 AS Select *From [dbo_tbl-Therapy Services SQL Update] WHERE ([Active OT] = 1) ORDER BY [Serving District]Asc, School Asc, [Last Name]ASC Go
Execute AllActiveOTStudentsEOY1; GO
With added parameters
CREATE Procedure AllActiveOTStudentsEOY2 @OTFullName nvarchar(255), @COTAFullName nvarchar(255) AS Select *From [dbo_tbl-Therapy Services SQL Update] WHERE ([Active OT] = 1) and [OT Full Name]=@OTFullName and [COTA Full Name]=@COTAFullName ORDER BY [Serving District]Asc, School Asc, [Last Name]ASC Go
This is the error I receive when I run the Execute Query
Msg 201, Level 16, State 4, Procedure AllActiveOTStudentsEOY2, Line 0
Procedure or function 'AllActiveOTStudentsEOY2' expects parameter '@OTFullName', which was not supplied.
Thanks again!
I'm not great with Stored Procedures either. From examples I've seen try adding the brackets I have in bold
CREATE Procedure AllActiveOTStudentsEOY2 (
@OTFullName nvarchar(255),
@COTAFullName nvarchar(255)
) AS
I was using this as reference
https://www.sqlservertutorial.net/sql-server-stored-procedures/stored-procedure-output-parameters/