Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Crystal Reports %appdata% system variable

Posted on 2013-11-12
17
Medium Priority
?
1,039 Views
Last Modified: 2014-01-10
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
Comment
Question by:cjohnson300
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +2
17 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39641881
What version of Crystal?

mlmcc
0
 

Author Comment

by:cjohnson300
ID: 39641887
11
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39641917
How are you running the reports?

mlmcc
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 

Author Comment

by:cjohnson300
ID: 39641923
at the moment as i'm still testing, the data is in an Access mdb held locally as is the Crystal report
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39642168
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
 

Author Comment

by:cjohnson300
ID: 39642359
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
 
LVL 18

Expert Comment

by:vasto
ID: 39642645
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
 

Author Comment

by:cjohnson300
ID: 39643944
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
 
LVL 35

Assisted Solution

by:James0628
James0628 earned 1000 total points
ID: 39644144
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
 
LVL 23

Accepted Solution

by:
Ido Millet earned 1000 total points
ID: 39644445
One of the 3rd-party Crystal UFLs listed at http://kenhamady.com/bookmarks.html#ufl provides a GetEnvironmentVar() function.
0
 

Author Comment

by:cjohnson300
ID: 39644521
how do i use these UFL files?!
0
 
LVL 23

Expert Comment

by:Ido Millet
ID: 39644558
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
 
LVL 18

Expert Comment

by:vasto
ID: 39645583
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
 

Author Comment

by:cjohnson300
ID: 39647440
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
 
LVL 18

Expert Comment

by:vasto
ID: 39648674
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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