×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Passing userid using ASP to a crystal report

Passing userid using ASP to a crystal report

Passing userid using ASP to a crystal report

(OP)
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

RE: Passing userid using ASP to a crystal report

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("Area")) <> 0 and Request.Form("lstArea") <> "All" Then
    strTemp1 = Request.Form("lstArea")
    intJ = 0
    For intI = 1 to Len(strTemp1)
        If Mid(strTemp1,intI,1) = "," Then
            intJ = intJ + 1
        End IF
    Next
    For intK = 1 to intJ
        intL = Instr(strTemp1,",")
        strTemp2 = Mid(strTemp1, 1,intL - 1)
        strTemp1 = Mid(strTemp1,intL + 2)
        If Len(strSQL) <> 0 then strSQL = strSQL & " OR "
        strSQL = strSQL & "{" & Session("Area") & "} = " & strTemp2
    Next
    If Len(strSQL) <> 0 then strSQL = strSQL & " OR "
    strSQL = strSQL & "{" & Session("Area") & "} = " & strTemp1
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set up the next line to modify the data to display in the report    
IF len(strSQL) <> 0 Then
    session("oRPT").recordselectionformula = strSQL
End If
On Error Resume Next                                                  
Session("oRpt").ReadRecords
If IsObject(session("oPageEngine")) Then                              
     Set Session("oPageEngine") = Nothing
End If
Set Session("oPageEngine") = Session("oRpt").PageEngine
Response.Redirect("SmartViewerActiveX.asp")

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close