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!

Insert users name on a report

Status
Not open for further replies.

dgillz

Instructor
Mar 2, 2001
10,043
US
This is almost a windows question rather than a crystal question.

How can I insert the User's name on a report? I thought this might be inder special fields, but it is not. Author is there, but that is not what I want. I want to see the user logged onto the machine where the report is executed.

I thought about a subreport in the page footer that pulls this information form the local file system, but I have no idea where to look for this.

Any ideas would be appreciated. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Hey Dgillz,

If each user has a specific database logon, you can source this from the user (or suser_name - depending on your database) column from your system table.

You'd have to use a sql expression or sub for that, as you wouldn't be able to link to a system table.

But if you want to specifically source the Windows username, I'd be at a loss. Sorry.

Naith
 
Whoops!

Hey Dgillz,

If each user has a specific database logon, you can source this from the user (or suser_<s>name - depending on your database) column from your system table.

You'd have to use a sql expression or sub for that, as you wouldn't be able to link to a system table.

But if you want to specifically source the Windows username, I'd be at a loss. Sorry.

Naith
 
Naith,

Sound good. I am clear on the subreport part. I still don't know what file to look at. You want to tell me how to do that? Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
You could use a sub report to bring back the most recently accessed &quot;*.PWL&quot; file from the Windows directory. I think it's updated everytime you log into Windows.
Mike

 
I don't have a windows directory, I have a winnt directory. I assume that is where I want to look.

Once I read that file what property says who the user was that last accessed it. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
I have no *.pwl files anywhere on my machine. Any other ideas? Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
I was interested in that .pwl malarky, but I don't seem to be able to find any pwl files if I search from root.

With regard to the database username, most dbs can identify users from system functions. I don't know what database you're connecting to, so if I give you Oracle examples, you'll probably see what I mean:

SQLPROMPT> SELECT username FROM user_users;

SQLPROMPT> show user

SQLPROMPT> SELECT user FROM dual;

All of these will return the username, but I think only 1 and 3 would work if you used a sql expression in your report. I don't think you can use subs now I think about it, as dual is actually a virtual table - and other databases would most likely hold similar information in virtual tables too.

Naith
 
Naith,

The question is not what database I am accessing, the question is what user is executing the crystal report. This is not stored in the data I that makes up my crystal report, so I do not see how the SQL above will help me.

Again, I would like to show the username in the page footer along with special fields such as print data and time, etc.
I was hoping that there is a file on the workstation somewhere that knows this.

Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Well, for me, on all my Oracle databases, if I create a sql expression on 'select user from dual', and dump the expression on the report, because all the users have specific database accounts rather than one crystal account that all the users share, I can get the user id.

Naith
 
A simpler solution might be just to have the user enter their name as a parameter Jim Broadbent
 
I think that Naith was suggesting that you return the user name from the database, not the database name. Your connection may not be user specific, in which case that wouldn't work anyway.

If users are executing reports based on unique sign ins, then it will work using the SQL Expression as he described:


An alternative would be to look for a UFL that provides the current user login (Chelseatech, Ido, or ???), I don't think that you can do this within CR otherwise.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top