Using the CurrentCEUserName function in a Crystal Report

Posted on 2007-08-03
Last Modified: 2013-11-15
I have a field called UserName which includes the firstintial last name field from a table called Store.
This matches the CurrentCEUsername from Crystal Resports Server that identifies our users.
The report I am working with is needing a group by store.
The report has to be set up so only the manager of the store sees the data from the his own store.
The tables that are involved are called Store and Users. They are linked by the STORE_ID.
How can I create a group that will match the CurrentCEUsername when the report should only show the the group value for the Store location. Like California Store or New York Store or Florida Store.

How do I make the CurrentCEUserName responsible for supressing a section when there is no relationship in the to the {store_id} other than the link between the tables.
I know where to put it in the Section Expert | Suppress Condition Box but not sure of the formula.
Now there is one manager per store in te near future we will have more than one manager per store how would that change the formula?
Question by:ruavol2
    LVL 100

    Assisted Solution

    You can try something like this

    CurrentCEUserName = {UserNameField}


    Author Comment

    What about if there is a range or several different managers.comming out of a field. I think I got that one it was the second part of that question that was tougher for me.

    Author Comment

    For mlmmc:
    My problem is different the client has the username that would match the CurrentCEUserName
    what I do not know how to do is they have a store and a maager say
    Store Name = Manager FirstIntial Last Name
    California     = TCruise
    Washington = BGates
    Oregon        = BSaxton
    Nevada        = FSinatra
    What I do not know how to do is realate that to the store. How do I make this work if I have no relationship to the store name which in this case would be California, Washington,Oregon or Nevada.
    Do I create a group with some kind of weird formula in it I am wondering if the database will need to be modified in order to make this happen. How do I say this store group equals the (CurrentCEUsername ={myfieldusername}) I do not know what I have to do? Please advise.
    LVL 42

    Accepted Solution

    Hi ruavol2,

    >>> How do I make this work if I have no relationship to the store name

    The simple answer is that you can't.  In order to make this work you will need to establish this relationship somehow.  You could create a complicated formula in your selection formula e.g.:

      (CurrentCEUserName = 'TCruise' and {Store} = 'California')
      (CurrentCEUserName = 'BGates' and {Store} = 'Washington')

    This means that your report changes everytime this relationship changes.  I would recommend creating a table in the database that contains this mapping (e.g.:  TCruise = California, etc.).  You can then add this table to your report - probably as the primary table and join your other tables to it.  Add a filter in your select expert to this table:

      {RelationShipTable.UserName} = CurrentCEUserName

    This will restrict the entries in this table to only the appropriate person and the join between this table and the others (join on state or store name or whatever) will insure all of the data from other tables is only for the correct store.  Another advantage is this same structure allows you to let one person view multiple stores.  If there is a manager just add them multiple times to this table:  (BMan = California, BMan = Oregon   <-- That would let Big Man see both states without any changes to your report).


    LVL 42

    Expert Comment

    Regarding your posted comment ( - be assured it isn't anything personal.  There aren't many people that respond routinely in this forum.  You'll get better response in the "Crystal Reports" forum generally.  

    As you noted, mlmcc is by far the most prolific responder and he knows his stuff so speaking for myself, when I see he's responded to a question I generally assume it's under control and move on.  Also, most experts only look at the most recent postings so if a question has gone stale it may be advisable to post a new 25 point question that points to the original with a plea for help - experts that missed the original question will be prompted to go back and look at it.


    LVL 100

    Expert Comment

    Glad i could help


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now