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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,212,927
Messages
6,110,718
Members
448,294
Latest member
jmjmjmjmjmjm

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