Solved

How to refresh the data of a report using the 'Refresh' button

Posted on 2002-07-10
14
342 Views
Last Modified: 2008-02-01
Greetings

I'm not sure what code is needed within the 'CRViewer1_RefreshButtonClicked' event to display changes in the data.  In other words, I've tried a couple different approaches but when the refresh button is clicked, the data is no different.  Here is what I've tried so far:

----------------------------------------------
Private Sub CRViewer1_RefreshButtonClicked(UseDefault As Boolean)

Form2.CRViewer1.Refresh

End Sub
----------------------------------------------

Private Sub CRViewer1_RefreshButtonClicked(UseDefault As Boolean)

 Call CreateRecordsets
 Report.Database.Tables.Item(1).SetDataSource ADOTest, 3
 CRViewer1.ReportSource = Report
 CRViewer1.ViewReport

End Sub    
----------------------------------------------

Neither of these two approaches worked, what am I missing?  Thanks.
0
Comment
Question by:John500
[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
  • 6
  • 2
14 Comments
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 7143874
Why not just let Crystal refresh the report using its default action?

private sub CRViewer1_RefreshButtonClicked(UseDefault as Boolean)
  UseDefault = true
end sub

Unless you need to insert some action into the refresh process, this should suffice.

DRRYAN3
0
 

Author Comment

by:John500
ID: 7143899
DRRYAN3,

Now that you mention it, I do already have some 'actions' within which ensure the report has the correct colors displayed.  Here's what I have and although it already has 'UseDefault = true', it doesn't work:

Private Sub CRViewer1_RefreshButtonClicked(UseDefault As Boolean)

    UseDefault = True
   
    Dim crSections As CRAXDRT.Sections
    Dim crSection As CRAXDRT.Section
    Dim crTextObject As Object
    Dim crReportObject As Object
   
    'Unload Form2
 
    Form2.Visible = True
    Form2.Enabled = False
    Form1.Command1.Visible = False
    Form1.Command3.Visible = True
    Form1.Visible = True
   
    Set crSections = Report.Sections
   
         For Each crSection In crSections
         
             crSection.BackColor = &HC0C0C0
             Report.Section1.BackColor = &H800000
             Report.Text1.TextColor = vbWhite
   
    Next crSection
   
   
End Sub

What do you think is wrong??
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 7143929
What's not working?   The color setup, or the data refresh?
0
Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

 

Author Comment

by:John500
ID: 7144097
The data refresh is definitely not working.  The color setup works fine.  I needed the code to adjust the color because during a print job, the colors are turned to black and white.  If the refresh button is clicked after a print job, the colors are black and white rather than blue...

0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 7144113
Does the data refresh work if you strip out the color setup code?  I don't see any problem with what you have there, but CR can be quirky sometimes.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7146896
listening
0
 

Author Comment

by:John500
ID: 7146945
DRRYAN3/mlmcc,

>> Does the data refresh work if you strip out the color setup code?

The answer to this question is no.  I got rid of the code related to the color and had to keep the following lines in order for the report to run right?  Any ideas at this point?  I'm wondering if the switch between forms causes the the refresh action to be cancelled because it really just displays the previous data, yes/no??  Thanks


Private Sub CRViewer1_RefreshButtonClicked(UseDefault As Boolean)

    Form2.Visible = True
    Form2.Enabled = False
    Form1.Command1.Visible = False
    Form1.Command3.Visible = True
    Form1.Visible = True

    UseDefault = True
   
End Sub
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 7147072
Why are you switching forms?  If you have the viewer control on one of the forms, that is the form which has to stay active in order for the refresh to occur.  As far as I know, you cannot have the same report instance active on two forms simultaneously.
0
 

Author Comment

by:John500
ID: 7147171
DRRYAN3,

The reason is this, Form1 handles parameter passing.  Thus, the user must first choose the appropriate value to proceed with the main the main query.  After Form1 obtains the parameter, it passes it to Form2 to reissue the query.

In regard to the 'same report instance' on two forms, that's not what's happening.  In other words, Form1 doesn't have a CRViewer, only a box with a drop down list for the user to choose a parameter.  The report does have a module and within the module a global declaration is made that looks like this:

Public Report As New CrystalReport1

So what do you think?
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 7147261
We may be discussing two different things here.

If you are changing the parameters which are driving the report, then this is best accomplished by closing the first instance of the report and starting over with a new instance of the report object and passing the new parameters to the new object.  The Refresh command of the report object is not designed to handle this type of action.

On the other hand, if you have had the report open for a while and now want to incorporate any new records into the report which have been added to the database (without changing the parameters), this is what the refresh command was designed to do.

Which scenario do you fall into?
0
 

Author Comment

by:John500
ID: 7157344
The parameters which are offered to the user do not change.  Therefore, the 2nd scenario is true.  However, I tend to think that even if the 1st scenario was true, the 'refresh' could still be accomplished with the appropriate code.

In any case, don't you think a command like

Form2.CRViewer1.Refresh

.... would do the trick??

Actually, this is exactly what I have in the Form1 code and that code was given to me (or suggested) by the CR tech people way back (2 years) when I first made the report.

What do you think?
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 7157416
You are correct - the refresh method of the viewer is supposed to reload the report from its original source.

In which form is your event handler for the refresh clicked?  I generally put it in the code for the form containing the viewer.  Once the viewer has been displayed in form2 it shouldn't be necessary to activate/deactivate form1 until the user has closed the viewer.

0
 

Author Comment

by:John500
ID: 7169976
DRRYAN3,

Form2 holds the code for the refreshed clicked event, which is the form containing the viewer.  When you say it shouldn't be necessary to activate/deactivate Form1 until the user has closed the viewer, I have to say my code doesn't work that way.  

That is, the viewer is not closed when the refresh button is selected.  What happens is, Form2 (the viewer) is disabled and then hidden because Form1 is displayed in order to offer the user a choice of input parameters, once the user chooses a parameter, Form2 is enabled and displayed.

However, not all of my reports require an input parameter and therefore, only contain one fomr (Form1) which contains the viewer.  The refresh button doesn't work for these reports either.........
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 75 total points
ID: 7200044
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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