Excel vba vs crystal reports

magnus101

New Member
Joined
Apr 11, 2012
Messages
36
I am running the same query from crystal reports and excel vba.
The crystal reports runs in about a second.
Excel VBA takes 26 seconds.

They both are going through the same ODBC connection.

The query comes directly from crystal reports > Database > Show SQL query

The vba code is simple.

Code:
  Dim cnDB As New ADODB.Connection
  
  Dim rsRecords As New ADODB.Recordset
  
  cnDB.Open "distributions"   
  rsRecords.Open "SELECT history.statusdate, saledetail.id, saledetail.saleqty, saledetail.todepot, saledetail.queue, sale.saledate, history.statusid, statustable.statustablename, saledetail.invoice, saledetail.backorder, saledetail.masdept, parts.masitemnumber, vendor.vendorname FROM   ((((logistics.history history INNER JOIN logistics.saledetail saledetail ON history.saledetailid=saledetail.id) INNER JOIN logistics.statustable statustable ON saledetail.statusid=statustable.id) INNER JOIN logistics.sale sale ON saledetail.saleid=sale.id) INNER JOIN logistics.parts parts ON saledetail.partsid=parts.id) INNER JOIN logistics.vendor vendor ON saledetail.vendorid=vendor.id  ", cnDB

Is there a reason for the time difference?
Am I doing something wrong in VBA?

thanks for any help
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,099
Messages
6,170,107
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top