Solved

Visual basic code to automatically refresh a crystal report

Posted on 2011-09-02
6
2,001 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:MECR123
[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
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:c1nmo
ID: 36473366
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?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36473830
ANother way that might work is to add the timer
On the tick event add

CRViewer1.Refresh

mlmcc
0
 

Author Comment

by:MECR123
ID: 36483047

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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:c1nmo
ID: 36483399
vb6 timer setup screenshot attached
ee-timer.png
0
 

Author Comment

by:MECR123
ID: 36483876
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
0
 
LVL 6

Accepted Solution

by:
c1nmo earned 250 total points
ID: 36484134
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.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

742 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