Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Lin100
Yak Posting Veteran
70 Posts |
Posted - 2008-03-18 : 13:56:05
|
Optional Parameters in Stored Procedure Did Not Return Any Records.Access 2002 (SP1) and SQL 2000 ServerI have an Access ADP form that have a combo box and a text box, and I wanted it to do the following:1) Whenever a user select a value from a combo box, but leave the text box blank, then Access will retrieve all of the records that meet the ONE criteria from the combo box.2) Whenever a user put in a value from a text box, but leave the combo box blank, then Access will retrieve all of the records that meet the ONE criteria from the text box.3) Whenever a user select a value from a combo box, and enter a value in the text box, then Access will retrieve all of the records that meet the TWO criteria - one from the combo box, and theother from a text box.Currently, Access only retrieve records when I select a value from a combo box and ignore the criteria of the text box value.Example of Error:combo box value: 100text box value: 1Result: Retrieve all records where the combo box value is 100 including records where thetext box value is 1, 2, 3 or otherwise.combo box value: 100text box value: BLANKResult: Retrieve all records in the table, regardless of whether or not the combo boxvalue is a 100.////////////////////////////////////////Form Name: frmParameters_2Combo Box Name: cboParameterText Box Name: Text_Au_OrdWhere: These 2 controls are located on the Form Header Of the Form frmParameters_2Form Name: frmParameters_2Record Source: byroyalty_2Input Parameters:@percentage int=Forms!frmParameters_2!cboParameter,@auord int=Forms!frmParameters_2!Text_Au_OrdTHE TWO PARAMETERS ABOVE ARE OPTIONAL PARAMETERS.IF NO parameter are given (combo box and text box are blank), then allrecords will be displayed on the form frmParameters_2.Text Box: txtAuIDWhere: On the Detail Section of The Form frmParameters_2////////////////////////////////////////CREATE PROCEDURE byroyalty_2 @percentage int, @auord intASselect au_id from titleauthorwhere titleauthor.royaltyper = @percentage OR @percentage IS NULLAND titleauthor.au_ord = @auord OR @auord IS NULLGO/////////////////////////////////////////Private Sub cboParameter_AfterUpdate()Me.RequeryEnd SubPrivate Sub Text_Au_Ord_AfterUpdate()Me.RequeryEnd Sub |
|
|
|
|
|
|