Visual basic code to automatically refresh a crystal report

MECR123
MECR123 used Ask the Experts™
on
hi

The following is the Visual basic code to create a executable option to call crystal reports

I would like to put in an automatic refresh into this code - every x minutes the crystal report is to be refreshed

what is the visual basic code for this and where in the code below would I put in this code ?


Private Sub Form_Load()
Dim CRapp As CRAXDRT.Application
Dim ConnectionInfo As CRAXDRT.ConnectionProperties
Dim con As CRAXDRT.ConnectionProperties
Dim rpt As CRAXDRT.Report
Set CRapp = New CRAXDRT.Application
Set rpt = CRapp.OpenReport("U:\file name.rpt")
Set ConnectionInfo = rpt.Database.Tables(1).ConnectionProperties
ConnectionInfo.Item("DSN") = "DSN"
ConnectionInfo.Item("Database") = "Database"
ConnectionInfo.Item("User ID") = "UserID"
ConnectionInfo.Item("Password") = "password"
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = rpt
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub


thanks
MECR
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Add a timer to the form and move the code to the timer tick event, remember to enable timer and set tick count.

Might also convert to run as service?
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
ANother way that might work is to add the timer
On the tick event add

CRViewer1.Refresh

mlmcc

Author

Commented:

Hi Guys

I'm not a VB person -
would you be able to explain in detail how I would do the above - I have VB 6.0
thanks
MECR
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Commented:
vb6 timer setup screenshot attached
ee-timer.png

Author

Commented:
Hi

thanks - i created this - so now I have 2 forms
the first form has the original code
the second form as the code as you stated above

I have created the executable object but the program does not refresh - I would like the crystal report to refresh every 10 minutes

regards
Commented:
Hi,
The timer will need to be on the same form as the crystal report viewer.  The sample above was just to show how the timer is setup.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial