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

Passing userid using ASP to a crystal report

Status
Not open for further replies.

jata1321

Programmer
Jul 26, 2001
2
0
0
US
I am using crystal reports for the first time and I have a problem and need your help . We have online reports which are generated dynamically . We are using ASP code and Lot of user's logon using their userid and access their reports . Is there a way I can pass this userid to the crystal reports and ask it to fetch the records for that particular userid only .

Right now the table that is used to show the results has more than one user's information and sometimes pops all the results thereby creating security issues .

Please advice
Thanks for your help
Jata
 
The code below is on one of my asp pages. I pass the name of a field that has an area code (1,2,3 etc), and a set of values from a multiple select box ("1,5,8") and I build an SQL statement that limits the results in the report to just the selected area's.

Hope this helps!
Harry

'Check the passed variables to see if an SQL string needs to be built
strSQL = ""
'Process the Area selection if any, skip if *All* is selected
'Session("Area") is the field name of the area in the database
'Request.Form("lstArea") is the result of a multiple selection dropdown box
'ie. "1,2,5,7,9"
If Len(Session(&quot;Area&quot;)) <> 0 and Request.Form(&quot;lstArea&quot;) <> &quot;All&quot; Then
strTemp1 = Request.Form(&quot;lstArea&quot;)
intJ = 0
For intI = 1 to Len(strTemp1)
If Mid(strTemp1,intI,1) = &quot;,&quot; Then
intJ = intJ + 1
End IF
Next
For intK = 1 to intJ
intL = Instr(strTemp1,&quot;,&quot;)
strTemp2 = Mid(strTemp1, 1,intL - 1)
strTemp1 = Mid(strTemp1,intL + 2)
If Len(strSQL) <> 0 then strSQL = strSQL & &quot; OR &quot;
strSQL = strSQL & &quot;{&quot; & Session(&quot;Area&quot;) & &quot;} = &quot; & strTemp2
Next
If Len(strSQL) <> 0 then strSQL = strSQL & &quot; OR &quot;
strSQL = strSQL & &quot;{&quot; & Session(&quot;Area&quot;) & &quot;} = &quot; & strTemp1
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set up the next line to modify the data to display in the report
IF len(strSQL) <> 0 Then
session(&quot;oRPT&quot;).recordselectionformula = strSQL
End If
On Error Resume Next
Session(&quot;oRpt&quot;).ReadRecords
If IsObject(session(&quot;oPageEngine&quot;)) Then
Set Session(&quot;oPageEngine&quot;) = Nothing
End If
Set Session(&quot;oPageEngine&quot;) = Session(&quot;oRpt&quot;).PageEngine
Response.Redirect(&quot;SmartViewerActiveX.asp&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top