PC Review


Reply
Thread Tools Rate Thread

TO ARM REPORT FROM BOOKS CLOSED - ADO

 
 
Oscar K
Guest
Posts: n/a
 
      26th May 2008
Hello friends: I request them help for the problem that I raise them next.


I keep the monthly sales in different books xls (SAL0108, SAL0208,
SAL0308,....etc.). The information is stored of the following way :


Code (code of article), Date (date of transaction) , Invoice (whole
invoices )


in a sheet I have the detail of the articles :

Code, Detail

I need to establish the comparative half-yearly one of sales for articles.


Ej.



ARTICLE DETAIL JANUARY FEBRUARY MARCH ........

1 XXXXX 1000 2000

2 XXXXX 4000
5000


The code that I wrote is more or less the following one :


Sub Sales()

I copy all the articles + detail in the sheet of the report


For fa = 1 To FinalArticle ' To cover Articles



Cod = it takes the code of article



For Month = 1 To 6

Fname= it takes the name of each of the books Ej.SAL0108.xls

SourceSheet$ = "Sheet1" Name of the eyelash



SourceRange$ = "A1:O1000" Range of search



I establish the connection





szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=" & Fname & ";" & _

"Extended Properties=""Excel 8.0;HDR=Yes"";"



Set rsCon = CreateObject("ADODB.Connection")

Set rsData = CreateObject("ADODB.Recordset")

rsCon.Open szConnect



smSQL = "SELECT SUM wSales as SumReg FROM [" & SourceSheet$ &
SourceRange$ & "] WHERE(Code = " & Cod & ")"


rsData1.Open smSQL, rsCon, 0, 1, 1 ' I execute the instruction



Sheets("Credit").Cells(fi + 2, co + 1) = rsData1!SumReg ' I copy it in the
sheet of reports

Next Month

Next fa ' line of articles


I erase the lines that have no movement


End Sub


The code works well, but it is slow, since I must establish the connections
for every article in the respective months. Might anybody indicate if there
exists some more rapid way of doing this?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How would i refer to a closed report? Chris K Microsoft Access Form Coding 8 17th Aug 2010 10:31 PM
Not sure if report is closed Richard Microsoft Access Reports 2 15th Jun 2007 08:03 AM
macro to change the names and delete closed books Tim Microsoft Excel Misc 2 6th Feb 2005 09:39 PM
Open report from form, then wait til report is closed before running rest of code? Jason Gyetko Microsoft Access 9 5th Mar 2004 07:01 PM
Open report from form, then wait til report is closed before running rest of code? Jason Gyetko Microsoft Access Forms 1 5th Mar 2004 03:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:25 PM.