Solved

Visual basic code to automatically refresh a crystal report

Posted on 2011-09-02
6
2,020 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 101

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
Independent Software Vendors: 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

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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