A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Crosstab queries and Recordsets in VBA



 
 
Thread Tools Display Modes
  #1  
Old June 5th, 2004, 01:51 AM
Tony
external usenet poster
 
Posts: n/a
Default Crosstab queries and Recordsets in VBA

Hi all,

I have an interesting issues trying to create a Recordset from a Crosstab query.

I am making a report with some graphs and I want to populate the graphs with data from a crosstab query which I have already defined and know works. There are no parameters involved.

When I open the report to populate the graphs, I create a recordset as follows:

Set qdef = CurrentDb.QueryDefs("MyCrosstab")
Set rst = qdef.OpenRecordset(dbOpenDynaset)

or as

Set rst=CurrentDb.OpenRecordset("MyCrosstab",dbOpenDyn aset)

While I get a recordset, it only has 1 record. It also returns immediately which is odd since my query takes a few seconds to run.

I can find nothing in the docuomentation, msdn, support forums, etc. which explains this behavior. I have also tried various type permutations of OpenRecordset, as well as moving this functionality out of the report object and into a module.

I can't believe that something this fundamental would be a bug, but I am beginning to wonder.

To duplicate the problem, create any normal and simple crosstab query and open it up in code as above. Please let me know if your Recordset contains your complete data or just the first record.

Thanks
Tony

  #2  
Old June 5th, 2004, 03:24 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default Crosstab queries and Recordsets in VBA

Usually, when you first open a Recordset, it is not fully populated and will
show the RecordCount of 1. You need to do a MoveLast before obtaining the
value of RecordCount to get the accurate RecordCount.

--
HTH
Van T. Dinh
MVP (Access)



"Tony" wrote in message
...
Hi all,

I have an interesting issues trying to create a Recordset from a Crosstab

query.

I am making a report with some graphs and I want to populate the graphs

with data from a crosstab query which I have already defined and know works.
There are no parameters involved.

When I open the report to populate the graphs, I create a recordset as

follows:

Set qdef = CurrentDb.QueryDefs("MyCrosstab")
Set rst = qdef.OpenRecordset(dbOpenDynaset)

or as

Set rst=CurrentDb.OpenRecordset("MyCrosstab",dbOpenDyn aset)

While I get a recordset, it only has 1 record. It also returns immediately

which is odd since my query takes a few seconds to run.

I can find nothing in the docuomentation, msdn, support forums, etc. which

explains this behavior. I have also tried various type permutations of
OpenRecordset, as well as moving this functionality out of the report object
and into a module.

I can't believe that something this fundamental would be a bug, but I am

beginning to wonder.

To duplicate the problem, create any normal and simple crosstab query and

open it up in code as above. Please let me know if your Recordset contains
your complete data or just the first record.

Thanks
Tony



  #3  
Old June 5th, 2004, 07:01 AM
Tony
external usenet poster
 
Posts: n/a
Default Crosstab queries and Recordsets in VBA

Hi Van,

Thank you. I am very thankful for your answer. It worked as you said.

However my curious analytical side is now asking questions. Is this normal procedure? Where is this documented? Of all my dealings with recordsets, and looking at examples, this is the first time I have run accross this. I am therefore curious as to what else I don't know about recordsets. Do you know of any good references?

Thanks again,
Tony
  #4  
Old June 6th, 2004, 02:00 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default Crosstab queries and Recordsets in VBA

It is in Access VB Help topic "RecordCount Property" (for DAO Recordset).

(checked in AXP)

--
HTH
Van T. Dinh
MVP (Access)


"Tony" wrote in message
...
Hi Van,

Thank you. I am very thankful for your answer. It worked as you said.

However my curious analytical side is now asking questions. Is this

normal procedure? Where is this documented? Of all my dealings with
recordsets, and looking at examples, this is the first time I have run
accross this. I am therefore curious as to what else I don't know about
recordsets. Do you know of any good references?

Thanks again,
Tony



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:48 AM.


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