G
Greg Snidow
Greetings all. I use the following stored procedure as the record source of
a search form. Basically it is as outlined in MS help
ALTER Procedure spMDUSearch
@CO nvarchar(50), @property_name varchar(100)
As
Declare @SQLString varchar(1000)
Declare @SelectList varchar(100)
SET NOCOUNT ON
SELECT @SelectList = 'SELECT * from tblmdu_tracking'
IF @CO Is NOT NULL
BEGIN
SELECT @SQLString = 'WHERE CO = ''' + @CO + ''''
END
IF @property_name Is NOT NULL
BEGIN
IF @SQLSTRING Is NOT NULL
BEGIN
SELECT @SQLSTRING = @SQLSTRING +
' AND property_name = ''' + @property_name + ''''
END
ELSE
BEGIN
SELECT @SQLSTRING = 'WHERE property_name = ''' +
@property_name + ''''
END
END
SELECT @SelectList = @SelectList + ' ' + @SQLString
EXECUTE(@SELECTLIST)
This works beautifully most of the time. I use combo boxes on a search form
to enter the parameter values to be passed to the procedure. The record
source of the combo boxes are fields in tblmdu_tracking. Some of the
property_name records have parentheses in them, like this 'FOUR WINDS AT
OAKTON CONDOS - ( FORMERLY: SUMMIT). When I choose these records for the
@property parameter I get an error that says 'Invalid SQL Statement. Check
the server filter on the form record source.' Is there something I can do to
allow the parentheses? Thank you
a search form. Basically it is as outlined in MS help
ALTER Procedure spMDUSearch
@CO nvarchar(50), @property_name varchar(100)
As
Declare @SQLString varchar(1000)
Declare @SelectList varchar(100)
SET NOCOUNT ON
SELECT @SelectList = 'SELECT * from tblmdu_tracking'
IF @CO Is NOT NULL
BEGIN
SELECT @SQLString = 'WHERE CO = ''' + @CO + ''''
END
IF @property_name Is NOT NULL
BEGIN
IF @SQLSTRING Is NOT NULL
BEGIN
SELECT @SQLSTRING = @SQLSTRING +
' AND property_name = ''' + @property_name + ''''
END
ELSE
BEGIN
SELECT @SQLSTRING = 'WHERE property_name = ''' +
@property_name + ''''
END
END
SELECT @SelectList = @SelectList + ' ' + @SQLString
EXECUTE(@SELECTLIST)
This works beautifully most of the time. I use combo boxes on a search form
to enter the parameter values to be passed to the procedure. The record
source of the combo boxes are fields in tblmdu_tracking. Some of the
property_name records have parentheses in them, like this 'FOUR WINDS AT
OAKTON CONDOS - ( FORMERLY: SUMMIT). When I choose these records for the
@property parameter I get an error that says 'Invalid SQL Statement. Check
the server filter on the form record source.' Is there something I can do to
allow the parentheses? Thank you