Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to bind a subform to stored procedure

Status
Not open for further replies.

childrenfirst

Technical User
Oct 15, 2006
80
US
Hi,

I have a subform called Result which returns the search result based on the criteria set by users on the main form.

I created a stored procedure which is executed correctly but returned no result because I think I did not bind the subform to the stored procedure correctly.

In Record source, I typed in EXEC [s_TimeOffSearchReults], but when I tried to bind each object to a field from the stored procedure, the field list was empty.

Please help!

Here is the stored procedure for your information:
CREATE PROCEDURE s_TimeOffSearchResults
@EmpName varchar(50) = NULL,
@SearchStartDate datetime = NULL,
@SearchEndDate datetime = NULL AS

DECLARE @sql nvarchar(4000),
@paramlist nvarchar(4000)

SELECT @sql =
'SELECT RequestID, EmpName, OffStartDate, OffEndDate, NumofDays, NumofOccurances, OffType
FROM TimeOff
WHERE 1 = 1 AND ('

IF @EmpName IS NOT NULL AND LEN(@EmpName) <> 0
SELECT @sql = @sql + ' EmpName = ''' + @EmpName + ''

IF @SearchStartDate <> '01/01/1900'
SELECT @sql = @sql + ' AND CONVERT(varchar,OffStartDate,101)=''' + CONVERT(varchar,@SearchStartDate,101) +''''

IF @SearchEndDate <> '01/01/1900'
SELECT @sql = @sql + ' AND CONVERT(varchar,OffEndtDate,101)=''' + CONVERT(varchar,@SearchEndDate,101) +''''

SET @sql = @sql + ')'

SELECT @paramlist = '@xEmpName varchar(50),
@xSearchStartDate datetime,
@xSearchEndDate datetime'

EXEC sp_executesql @sql, @paramlist,
@EmpName,@SearchStartDate,@SearchEndDate
GO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top