Solved

Visual basic code to automatically refresh a crystal report

Posted on 2011-09-02
6
1,867 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

18 Experts available now in Live!

Get 1:1 Help Now