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

Setting parameters to default to different values for diff pcs

Status
Not open for further replies.

josefin

Programmer
Oct 29, 2002
26
NZ
I have several users running a compiled crystal report which is located on the network. I am wondering if there is any way for me to have the values of the parameters default to different values depending on what pc the report is running from. It doesn't seem like it will be possible but some of you may have come across a similar problem before.
 
Dear Josefin,

Depending on the database you are reporting against, you may be able to capture the username (I assume this even better than machine, because it would be whatever they log in with)using a SQL expression.

In SQL Server the expression is written:


{fm User()}

So you could actually use an if statement:

If select {%user} = "Bob" then {?Parameter} = "Blah Blah
else ...

Hope that was helpful,

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
I think that Crystals lack of support for Dynamic parameters is their greatest weakness.

If you're trying to differ the choices that the user can select from, then you're fairly limited in this regard, as they can only be updated by opening and saving the report, though external code can create this event.

If you're trying to limit rows based on which user is logged on, then Ro has the solution, though I wouldn't bother using parameters, just hardcode the choices based on the user who's logged in.

On SQL Server I use the following to get the user who's logged in to the database:

(substring(suser_sname(),(charindex('\',suser_sname()) + 1),25))

-k kai@informeddatadecisions.com
 
I just noticed a typo in my expression above.

It should be {fn User()} not in {fm...

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Hmm,

I know this won't work in t-sql but it is what works in Crystal. I don't know why. I just tested this again and the syntax for crystal is as posted. The expressions are driver specific and I happen to be using the Microsoft SQL server odbc driver version 03.81.7713

You are right about in SQL itself - I use exactly what you show in SQL.

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Thanks for your input. Unfortunately I am not using SQL server. I am running the report off a network so there is no easy way to know who is logged in. I had considered making users "log in" to the report then defaulting parameters that way - but that seems pointless and difficult to maintain so I have decided to leave my report as is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top