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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter arrays used to select records via an intranet

Status
Not open for further replies.

arh

Programmer
Aug 17, 2000
19
US
When I create a parameter field that allows multiple discrete values to be entered. How do I assign these entered values to the parameter array in the parameters collection within an Active Server Page

I'm using the following ASP code:


set ParamDefCollection = Session("oRpt").Parameterfields

'this creates the parameter collection
set session("Param") =ParamDefCollection

'this creates the parameter
set MyParam1 =session("Param").item(1)

'this sets it's value
call MyParam1.SetCurrentValue(Cdate("xxxx"),10)

How do you set multiple values for the one parameter?
 
This code took me MANY hours to proof, but I will share for FREE ;-)

Code:
For each Item in objParamCollection

	response.write(&quot;<b>&quot; & Item.ParameterFieldName & &quot;</b><br>&quot; & vbcrlf)
	response.write(Item.Prompt & &quot;<br>&quot; & vbcrlf)
	
	if Item.NumberOfDefaultValues > 1 then 
		'Pick list
		if Item.EnableMultipleValues = True then
			'LIST combo box
			response.write(&quot;<select name=&quot; & Item.ParameterFieldName & &quot; size=5 multiple>&quot; & vbcrlf)
		else
			'We normal combo box
			response.write(&quot;<select name=&quot; & Item.ParameterFieldName & &quot;>&quot; & vbcrlf)
		end if

		'Get Table and field name from parameter name
		strTable = Item.ParameterFieldName
		While (Right(strTable, 1) <> &quot;.&quot; And Len(strTable) <> 0)                      
			intLen = Len(strTable) - 1                                                  
			strTable = Left(strTable, intLen)
			strField = Right(Item.ParameterFieldName, len(Item.ParameterFieldName)-intLen)
		Wend   
		strTable = Left(strTable, intLen-1)
		if session(&quot;bDebug&quot;) = TRUE then Response.Write (strTable & &quot;<br>&quot; & strField & &quot;<br>&quot;)
		
		'Fetch field values based on parameter name.
		strSQL = &quot;select DISTINCT &quot; & strField & &quot; from &quot; & strTable
		if session(&quot;bDebug&quot;) = TRUE then Response.write (strSQL)
		set objRS = server.createobject(&quot;ADODB.Recordset&quot;)
		objRS.Open strSQL, objConn
		
		Do While Not objRS.EOF
			response.write(&quot;<option>&quot; & objRS(strField) & &quot;</option>&quot; & vbcrlf)
			objRS.MoveNext 
		Loop
		response.write(&quot;</select><br><br>&quot; & vbcrlf)
		
		'Clean Up
		objRS.Close
		set objRS = nothing
	else
		'Text
		if Item.MaximumValue > 50  or Item.MaximumValue < 1 then 
			response.write(&quot;<input type=TEXT name=&quot; & Item.ParameterFieldName & &quot; value='&quot; & Item.DefaultValue & &quot;' size=50><br><br>&quot; & vbcrlf)
		else 
			response.write(&quot;<input type=TEXT name=&quot; & Item.ParameterFieldName & &quot; value='&quot; & Item.DefaultValue & &quot;' size=&quot; & Item.MaximumValue & &quot; maxlength=&quot; & Item.MaximumValue & &quot;><br><br>&quot; & vbcrlf)
		end if
	end if
	
next

Steven Fowler
e-Business Intelligence ExpertsTM
wpe1.gif

We specialize in:
Crystal Report Authoring
Seagate Info Deployment
Data-warehouse and Data-mart Development
Infrastructure Planning
Seagate Crystal Report and Info Training
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top