Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR9 delayed with Access tables 1

Status
Not open for further replies.

Periko

Programmer
Feb 24, 2003
134
BE
Hello,

I'm using VB6 with access2000 and CR9. In VB, i'm calling a form on which my printpreview is shown. To print, i'm using a query to get the data from the database, store this to a temp database, where I store all my data to print. In vb, i do this query and call the print-form. sometimes my printform shows me an empty preview. After pressing the refresh-button a few times, my data appears in the printform. It's like the printform is executed before my temp-table is filled up. Anyone had this problem ?

Pedro...
 
I can duplicate the issue, but I'm not sure if it's necessarily a Crystal issue, or more of a timing issue between VB > Access > Crystal.

A potential workaround would be to create a recordset from the temp table after it's been updated, then set the report's data source to the recordset instead of having it access the table directly.

This worked for me:
Code:
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
Set cmd.ActiveConnection = adoConn

cmd.CommandType = adCmdText

'Clear out the current contents of the Temp table
cmd.CommandText = "DELETE FROM TempTable"
cmd.Execute

'Fill the temp table
cmd.CommandText = "" & _
    "INSERT INTO TempTable (Field1, Field2, Field3) " & _
    "SELECT Customer.[Customer Name], Customer.[Contact First Name], " & _
    "Customer.[Contact Last Name] " & _
    "FROM Customer;" 

cmd.Execute 

'Open a recordset with the data from the Temp table
rst.Open "SELECT * FROM TempTable", adoConn

'Declare the Report object, and open the report
Dim crxRpt As CRAXDRT.Report
Set crxRpt = crxApp.OpenReport(App.Path & "\Report1.rpt")

'Set the report's data source to the newly created recordset
crxRpt.Database.SetDataSource rst

'Preview the report
CRViewer.ReportSource = crxRpt
CRViewer.ViewReport

By using the SetDataSource method, the report should accept the recordset as its data source, and not attempt to access the temp table directly.

-dave
 
Hello Vidru,

this seems fine, however, i found a solution for myself easier to do. I can keep my stuff like it is, just in the print-it form where i show the print-preview, i made a for-next structure with a doevents in between. For x = 1 to 100000. This gives the necessary delay between the fill of my recordset and the execution of the print-preview.

Thx anyway...

Pedro...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top