Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ADO Recordset.Filter in Excel 2002

Hi All
Have been using Excel to generate custom reports on data from remote
databases quite happily.
I now have a need to avoid making lots of calls to the DB by downloading the
complete table concerned and using a rsABC.Filter in a loop to do a
different multi-column FIND in each iteration to get the various records I
need.
However any statement as ' rsABC.Filter "..." ' throws a compile error
'Invalid Use of property' with the '.Filter' highlighted.


Any suggestions as to what I am missing will be much appreciated.

TIA

Dash


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default ADO Recordset.Filter in Excel 2002

Make sure you set the RS "cursorlocation" to "client". I forget the exact
syntax.
Once the recordset is complete you can then disconnect it from the DB
(unless you're doing updates in which case you might be better off leaving
it connected).

Good code sample he
http://www.4guysfromrolla.com/webtech/080101-1.shtml


Tim



"Dash" wrote in message
...
Hi All
Have been using Excel to generate custom reports on data from remote
databases quite happily.
I now have a need to avoid making lots of calls to the DB by downloading
the complete table concerned and using a rsABC.Filter in a loop to do a
different multi-column FIND in each iteration to get the various records I
need.
However any statement as ' rsABC.Filter "..." ' throws a compile error
'Invalid Use of property' with the '.Filter' highlighted.


Any suggestions as to what I am missing will be much appreciated.

TIA

Dash



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ADO Recordset.Filter in Excel 2002

Thanks Tim but I am still missing something!!
I used the 4guys example for a disconnected RS - as it in Excel VBA I had
to 'type' the Dim statements.
If I try to use the returned RS I get error msg. 'Operation not allowed when
the object is closed.'

If I comment out the lines in the 4guys function closing the oRS then the
returned rs is 'open'
i.e. RS.RecordCount returns without error.
but RS.Filter throws the same compile error 'invalid property assignment'

I tried typing the returned RS as Recordset, ADODB.Recordset and Variant

Anybody got any further thoughts??

Dash


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...
Make sure you set the RS "cursorlocation" to "client". I forget the exact
syntax.
Once the recordset is complete you can then disconnect it from the DB
(unless you're doing updates in which case you might be better off leaving
it connected).

Good code sample he
http://www.4guysfromrolla.com/webtech/080101-1.shtml


Tim



"Dash" wrote in message
...
Hi All
Have been using Excel to generate custom reports on data from remote
databases quite happily.
I now have a need to avoid making lots of calls to the DB by downloading
the complete table concerned and using a rsABC.Filter in a loop to do a
different multi-column FIND in each iteration to get the various records
I need.
However any statement as ' rsABC.Filter "..." ' throws a compile error
'Invalid Use of property' with the '.Filter' highlighted.


Any suggestions as to what I am missing will be much appreciated.

TIA

Dash





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default ADO Recordset.Filter in Excel 2002

Post the code which doesn't work - it's easier than having us apply any
changes you may have made to the original.

Tim

--
Tim Williams
Palo Alto, CA


"Dash" wrote in message
...
Thanks Tim but I am still missing something!!
I used the 4guys example for a disconnected RS - as it in Excel VBA I had
to 'type' the Dim statements.
If I try to use the returned RS I get error msg. 'Operation not allowed

when
the object is closed.'

If I comment out the lines in the 4guys function closing the oRS then the
returned rs is 'open'
i.e. RS.RecordCount returns without error.
but RS.Filter throws the same compile error 'invalid property assignment'

I tried typing the returned RS as Recordset, ADODB.Recordset and Variant

Anybody got any further thoughts??

Dash


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...
Make sure you set the RS "cursorlocation" to "client". I forget the

exact
syntax.
Once the recordset is complete you can then disconnect it from the DB
(unless you're doing updates in which case you might be better off

leaving
it connected).

Good code sample he
http://www.4guysfromrolla.com/webtech/080101-1.shtml


Tim



"Dash" wrote in message
...
Hi All
Have been using Excel to generate custom reports on data from remote
databases quite happily.
I now have a need to avoid making lots of calls to the DB by

downloading
the complete table concerned and using a rsABC.Filter in a loop to do

a
different multi-column FIND in each iteration to get the various

records
I need.
However any statement as ' rsABC.Filter "..." ' throws a compile error
'Invalid Use of property' with the '.Filter' highlighted.


Any suggestions as to what I am missing will be much appreciated.

TIA

Dash







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default ADO Recordset.Filter in Excel 2002

Try removing these two lines from your GetRS function

oRS.Close
Set oRS = Nothing

Tim
--
Tim Williams
Palo Alto, CA


"Dash" wrote in message
...
Tim
wasn't sure how best to 'post' the code so I have attached the xl file and
pasted the the vba code below.
Your help is much appreciated.
Dash

Public Sub DisConnTest() 'based on 4guys example
Dim RS As ADODB.Recordset
Dim RcdCnt As Long
'call the function
strSQL = "SELECT * FROM Authors"
Set RS = GetRS(strSQL)
'What has to happen here in order to access and operate on RS??
'RS.Open

RcdCnt = RS.RecordCount
End Sub

Function GetRS(strSQL)
'this function returns a disconnected RS

'Set some constants
Const adOpenStatic = 3
Const adUseClient = 3
Const adLockBatchOptimistic = 4

'Declare our variables
' Dim oConn
' Dim oRS
Dim oConn As ADODB.Connection
Dim oRS As ADODB.Recordset

'Open a connection
Set oConn = New ADODB.Connection
' Set oConn = Server.CreateObject("ADODB.Connection")
' oConn.Open mydsn, Sean, Grimaldi
oConn.Open "PubTest", "test1", "test1"
'Create the Recordset object
' Set oRS = Server.CreateObject("ADODB.Recordset")
Set oRS = New ADODB.Recordset
oRS.CursorLocation = adUseClient

'Populate the Recordset object with a SQL query
oRS.Open strSQL, oConn, adOpenStatic, adLockBatchOptimistic

'Disconnect the Recordset
Set oRS.ActiveConnection = Nothing

'Return the Recordset
Set GetRS = oRS

'Clean up...
oConn.Close
oRS.Close
Set oConn = Nothing
Set oRS = Nothing
End Function




"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Post the code which doesn't work - it's easier than having us apply any
changes you may have made to the original.

Tim

--
Tim Williams
Palo Alto, CA


"Dash" wrote in message
...
Thanks Tim but I am still missing something!!
I used the 4guys example for a disconnected RS - as it in Excel VBA I
had
to 'type' the Dim statements.
If I try to use the returned RS I get error msg. 'Operation not allowed

when
the object is closed.'

If I comment out the lines in the 4guys function closing the oRS then

the
returned rs is 'open'
i.e. RS.RecordCount returns without error.
but RS.Filter throws the same compile error 'invalid property

assignment'

I tried typing the returned RS as Recordset, ADODB.Recordset and

Variant

Anybody got any further thoughts??

Dash


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...
Make sure you set the RS "cursorlocation" to "client". I forget the

exact
syntax.
Once the recordset is complete you can then disconnect it from the DB
(unless you're doing updates in which case you might be better off

leaving
it connected).

Good code sample he
http://www.4guysfromrolla.com/webtech/080101-1.shtml


Tim



"Dash" wrote in message
...
Hi All
Have been using Excel to generate custom reports on data from remote
databases quite happily.
I now have a need to avoid making lots of calls to the DB by

downloading
the complete table concerned and using a rsABC.Filter in a loop to

do
a
different multi-column FIND in each iteration to get the various

records
I need.
However any statement as ' rsABC.Filter "..." ' throws a compile
error
'Invalid Use of property' with the '.Filter' highlighted.


Any suggestions as to what I am missing will be much appreciated.

TIA

Dash












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2002 Filter Chris waller Excel Discussion (Misc queries) 4 August 24th 09 09:03 PM
excel 2002 data filter Ivanko New Users to Excel 2 February 14th 09 04:12 PM
Excel 2002: How to use Auto Filter ? Mr. Low Excel Discussion (Misc queries) 2 December 1st 08 07:38 AM
Excel 2002 - Is it possible to use Data,Filter,Autofilter as X-Axi Birmangirl Charts and Charting in Excel 5 May 1st 05 01:42 AM
Recordset Filter by Array Kou Vang[_2_] Excel Programming 0 February 1st 05 04:31 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"