Get data for only last three months

P

poppy

Hi Jim and Tom

Thanx for your quick reply.

I tried your code and it works fine: For m = curMonth - 3\ -4 T
curMonth - 1.

The only problem is that a couple of columns in the spreadsheet ar
skipped before the data is inserted. In other words when I say it mus
only give me data for the last three months, it skips 7 columns befor
displaying the data
 
T

Tom Ogilvy

Possibly:

cn.Open cString

j = 0
For m = curMonth - 3 To curMonth - 1
j = j + 1
MerchantMonthly = "select branch, sum(qty), sum(b.vat)" & _
" from service_providers a left outer join cb b on a.sp_name = b.sp_name
and month" & _
" (inv_date) = " & m & " and year(inv_date) = " & curYear & " order by
a.sp_name"

If rs.State = -1 Then rs.Close

rs.Open MerchantMonthly, cn, adOpenKeyset, adLockOptimistic, adCmdText


'dump data into excel by calling function
Call PopulatePage(j) '<=== change m to j
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top