Solved

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

Posted on 2002-07-10
14
336 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
  • 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
 

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 100

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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 100

Accepted Solution

by:
mlmcc earned 75 total points
ID: 7200044
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

17 Experts available now in Live!

Get 1:1 Help Now