Solved

Visual basic code to automatically refresh a crystal report

Posted on 2011-09-02
6
1,897 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

21 Experts available now in Live!

Get 1:1 Help Now