Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

graph with access database - im on vb6 2

Status
Not open for further replies.
peraph is your first your help for me... (bho)

three question...
-1 in my case the current project have a fixed 30 shape, in my access the fields are 74... how to create dinamiclly the shape element
-2 in my case i can have a negative number in PERC, in this case the shape it must go below and not above
-3 i need to use the value in recordest not in a rnd


 
>peraph is your first your help for me

???

>how to create dynamically the shape element

So you've decided that the way to do this is by programmatically creating shapes, presumably to create the bars of a bar chart, or slices of a pie chart (etc).

Why not consider the control that Microsoft provide for exactly this purpose - the Microsoft Chart Control.
>i need to use the value in recordest not in a rnd
You can directly feed the Chart control a recordset* (with the ANNO and PERC columns)

> in my case i can have a negative number in PERC, in this case the shape it must go below and not above

So, a bar chart. And yes, I know how barcharts work with negative numbers ...


* There is actually a slight challenge here depending on the regional decimal symbol in use on the PC that will be running the code, since you seem to have elected to make PERC a text column which needs to be converted to a number



 
hI strong, use the best and symple way to do tath.
A msgraph is the same. Tks
 
Can't believe I am doing this, given your apparent unwillingness to do anything to help yourself, but:

Code:
[COLOR=blue]Option Explicit

[COLOR=green]' requires a Microsoft Chart Control on the form[/color]
Private Sub Form_Load()
    Dim rs As New ADODB.Recordset
    Dim cnn As ADODB.Connection

    Set cnn = New ADODB.Connection
    With cnn
        '.Provider = "Microsoft.ACE.OLEDB.12.0" [COLOR=green]'depends which version of Access we are working against[/color]
         .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "User ID=Admin;password= ;" & " Data Source=F:\test.mdb;" [COLOR=green]'path to your mdb file goes here[/color]
        .CursorLocation = adUseClient
        .Open
        
        [COLOR=green]'rs.Open "SELECT cstr(ANNO), cdbl(PERC) FROM TABELLA_STORIA", cnn, adOpenStatic, adLockReadOnly   [COLOR=green]'  assumes regional decimal seperator is a comma  since that is what is being used in PERC field[/color][/color]
        rs.Open "SELECT cstr(ANNO), [SERVIZIO]/100 AS PERC FROM TABELLA_STORIA", cnn, adOpenStatic, adLockReadOnly   [COLOR=green]'since PERC appears to actually be SERVIZIO/100 this works whatever regional decimal symbol is in use[/color]

        rs.MoveFirst [COLOR=green]' make sure first row is available to chart[/color]
        Set MSChart1.DataSource = rs
        rs.Close
    End With
End Sub

Private Sub Form_Resize()
    If WindowState <> vbMinimized Then
        MSChart1.Move 0, 0, ScaleWidth, ScaleHeight
    End If
End Sub[/color]
 
TKS strong.
only one...
possible to paint the bar in green for positive bar number, and in red negative bar number?
 
The VB6 chart control does not support different colours for different values in a series, I'm afraid.

 
Hi strong,
if you see in the form(chart.zip) are present 30 shape.
Is possible via code to create instead the current 30 shapes a dinamic number of shape for example 47 shapes, started for the shape array(0)?
 
I'm afraid that I am NOT going to write you a graphing utility. But in answer to your question, of course it is possible
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top