Solved

MS Graph Row Count

Posted on 2003-11-28
3
445 Views
Last Modified: 2007-12-19
I'm trying to query the number of rows returned from a MS Graph object. The RowSource is set to a SQL stmt. I then want to know if any records were returned for graphing. I've tried the following to return # of columns:

  If Me.OLEGraph1.ColumnCount < 1 then ...

but the ColumnCount always seems to = 0. Any ideas on how to query for Rows, or if any records were returned?

0
Comment
Question by:lilputian
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
svenkarlsen earned 100 total points
ID: 9840619
Hi lilputian,

You could check the recordcount by running the same query from a function:

Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset

Set cnn = CurrentProject.Connection
rst.ActiveConnection = cnn
rst.Open SQLstr, cnn, adOpenKeyset, adLockOptimistic
rst.movelast

If rst.RecordCount > 0 Then
    Debug.Print "Found " & rst.RecordCount & " records"
end if


Kind regards,
Sven
0
 
LVL 1

Author Comment

by:lilputian
ID: 9840762
Seems inefficient doesn't it?  Is there no way to check for returned records .. with a listbox I use '.listcount'.  
0
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9840846
Lilputian,

it may appear inefficient, but please remember that the Graph is not Access, but a separate application. You can probably retrieve info on the number of rows/records involved in a current graph, but that would mean using the Graph application-object as interface.

I prefer to avoid doing so. I don't use the Graph in that way, so I can't say anything about the Graph application-object, but I know how things get slowed down by use of the Word or Excel application.

You could try:
    myVar = Me.myChart.Application.DataSheet.Rows.count

where Mychart is the name of your Graph object on your form.

Which approach to choose depends on the size of the database supplying the data for the Graph, of course.

Also have a look at:
   http://msdn.microsoft.com/library/en-us/vbagr10/html/grtocObjectModelApplication.asp

to learn more about programming for the Graph object.


Sven
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question