• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1058
  • Last Modified:

Crystal Reports %appdata% system variable

I am trying to return a file path in a Crystal Report to point an OLE object to a picture file via the Graphic Location functionality, but I can't get it to work using the %appdata% system variable.

When I use an absolute path (C:\Documents and Settings\ . . . . ) it works fine.  

I did read somewhere that Crystal Reports doesnt have access to those variables, but was wondering if anyone knew of a workaround?

Many thanks in advance
0
cjohnson300
Asked:
cjohnson300
  • 6
  • 3
  • 3
  • +2
2 Solutions
 
mlmccCommented:
What version of Crystal?

mlmcc
0
 
cjohnson300Author Commented:
11
0
 
mlmccCommented:
How are you running the reports?

mlmcc
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
cjohnson300Author Commented:
at the moment as i'm still testing, the data is in an Access mdb held locally as is the Crystal report
0
 
mlmccCommented:
How do you plan to run the reports?

I don't think you can access the system variables.

You could access the value in an application that runs the reports and pass the value to the report in a parameter.  The parameter can then be used in the formula for the object location

mlmcc
0
 
cjohnson300Author Commented:
unfortunately that's not an option, the report is going to be called from an application but I dont have access to the code of the application.
0
 
vastoCommented:
If you are using R-Tag viewer you can create a formula like this one:

value = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

Open in new window


Then use this formula as it is shown in this vide0:
http://www.youtube.com/watch?v=ADXiP24N6Fw
(The sample is for current user name , which is another Environment variable)

If you are not using R-Tag viewer you can request a free license from this page:
http://www.r-tag.com/Pages/FreeCrystalReportsViewer.aspx 

Another option is to search for a custom UFL (or write one). This one comes with source code so you can just add a new function to return %appdata% : http://www.viksoe.dk/code/u2lwin32.htm

There might be some others on the market, which provide this feature.
I don't think UFL is the best option - if it is paid the price will be similar to a viewer and you will still need to run the report somehow. Also UFLs are usually 32 bits COM objects so you will be restricted to the 32 bits world. However if you are already set with a viewer this will be the only option.
0
 
cjohnson300Author Commented:
thanks for the post but I'm not using the r-tag viewer, and i guess if i did i would have to roll it out to every user of my application?
0
 
James0628Commented:
It's not really pretty, but one option might be to store the %appdata% value in a table, and then use a subreport in the report header to read that value and save it in a shared variable, and then use that shared variable to set the location for your image files.

 James
0
 
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
One of the 3rd-party Crystal UFLs listed at http://kenhamady.com/bookmarks.html#ufl provides a GetEnvironmentVar() function.
0
 
cjohnson300Author Commented:
how do i use these UFL files?!
0
 
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
A UFL library is a dll file. Once installed (or copied to the appropriate folder), the functions inside that dll become "Additional Functions" inside Crystal Designer, so you can create formulas using them. The UFL I was referring to has ~60 such functions (including the GetEnvironmentVar() function).

You would need to deploy the dll to any machine that runs a report with formulas that rely on these Additional Functions (either using Crystal Designer or any 3rd-party Crystal Viewer Application).

As mentioned above, you can create a UFL yourself.
0
 
vastoCommented:
Which application are  you using ?

I am confused. You mentioned that you cannot change it but you a referring to it as "my" application. If it is a 3rd party software and doesn't support basic stuff like that, what is the purpose to have it?  As I mentioned, If you are stuck with your current application you need to use an UFL. If you can develop your own UFL this will be fine, but If you are going to implement an existing one you may face the same issue tomorrow ( with another not supported function). If you are going to pay for UFL licenses,  consider the fact that you need to provide it to all users too,  and for almost the same price you can upgrade to R-Tag  (or similar application) and resolve the current and the future issues.
0
 
cjohnson300Author Commented:
i didnt refer to it as my application, but what happens is that the application invokes Crystal runtime when a report is run, and I'm not sure how i would tell the client machine to use a different report viewer
0
 
vastoCommented:
Crystal report should be configured before you to be able to run it. The main reason is that connection password is not saved with the report. You will either add few reports to your application and configure them, providing connection information and other settings or you will use Integrated security , which means you should manage user's permission on the database side. Of course you may use database, which does not require login ( like Access) but this will be one of the future problems you will face. So the way how this works is :
 1 administrator will add and configure few reports
 2 the user will open the viewer , select a report and run it

Any viewer will work like this, except the one from SAP, which is not able to refresh the data and for this reason does not require connection info.

It is hard to give you an advice without knowing details about the environment so I would suggest you to contact some of the Crystal reports viewers vendors and  discuss with them the options and the price of the solutions. You can find a list of vendors here : http://kenhamady.com/cru/comparisons/crystal-reports-viewers

As mentioned, I would not recommend UFL , but this is always an option in case you cannot find another solution. If you cannot develop your own and you are ready to purchase a licensed UFL,  contact Ido Millet - his UFL will provide you a way to resolve your current problem and  he has a good reputation for implementing user requests.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 6
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now