Results 1 to 3 of 3

Thread: [1.0/1.1] OpenFileDialog breaks Crystal Reports

  1. #1

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    [1.0/1.1] OpenFileDialog breaks Crystal Reports

    I want to pass the filename and location of an image to a Crystal Report.

    This works fine if I hardcode the image path such as
    Code:
    string ImagePathTest = @"C:\temp\image.jpg";
    myRpt.SetParameterValue("ImagePath", this.lblImagePath.Text);
    
    //OR
    
    myRpt.SetParameterValue("ImagePath", @"C:\temp\image.jpg");
    But I can't use an openFileDialog to select the image as I always get "Report Load Failed".

    This happens even if I don't use the file selected from the dialog. i.e. just clicking on the openfileDialog but passing hardcoded strings causes the report to fail to load.

    I even tried adding a new form before this one that contained an openFileDialog and passed the file path but the result was the same.

    It's as if just opening the OpenFileDialog is causing the report to not load!

    Thanks in advance.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] OpenFileDialog breaks Crystal Reports

    I'll wager that your report is using the current directory, i.e. the value in Environment.CurrentDirectory. When you change the path in a FileDialog it changes the current directory. By default that change remains after the FileDialog closes. If you set the RestoreDirectory property to True then the original path of the current directory will be restored when the FileDialog closes. I'm willing to bet that that will fix your problem.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [1.0/1.1] OpenFileDialog breaks Crystal Reports

    Ah that all sounds very reasonable, so I'm not prepared to take your wager. Instead I'll just try it out.

    Cheers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width