Solved

MS Graph Row Count

Posted on 2003-11-28
3
456 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

830 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