Jump to content
Software FX Community

Re: ado help


Software FX
 Share

Recommended Posts

Steve,

You are definitely an asset to this Newsgroup. Thank you very much.

--

Frank

SFX

"SteveT" <stephent@compassadv.com> wrote in message

news:orQhMXxJAHA.1428@sfxserver.softwarefx.com...

Ok Dan,

I use Access 2000 but I think the only change you'll have to make is the ADO

connection.

You would

Steve

Consider a table tblSales:

Territory Sales

East $100,000.00

West $350,000.00

South $205,000.00

North $105,000.00

Insert a ChartFX object on a form and the following code will create an ADO

recordset, ChartFX Data Object

and add the Data Object to the Chart Object.

You'll note I "stole" the SoftwareFX help file code, re-arranged a bit and

commented out

what wasn't necessary for this example.

Steve

Sub YourRoutine()

'Create variables for ADO Connection and Resultset

Dim Conn As ADODB.Connection

Dim rs As ADODB.Recordset

Dim ChartFX1 As ChartfxLib.ChartFX

Set ChartFX1 = Me.ChartFX1.Object

'Create variable to hold the Chart FX Default Data provider

Dim CfxData As Object

'Open the connection

'From the point of view of Access 2k, "Current Open Mdb"

Set Conn = CurrentProject.Connection

'In VB you'd set this probably like:

' Open a connection using the Microsoft Jet provider.

'Set Conn = New ADODB.Connection

'Conn.Provider = "Microsoft.Jet.OLEDB.4.0"

'Conn.Open "C:\Samples\northwind.mdb", "admin", ""

'Execute SQL and obtain resultset

Set rs = Conn.Execute("SELECT Territory, Sales FROM tblSales;")

'Create Ado object from the Chart FX Resultset

Set CfxData = CreateObject("CfxData.Ado")

'Assign the ADO resultset to the ChartFX Data Provider

CfxData.ResultSet = rs

'The way Chart FX interprets the SQL Statement.

'Chart FX will apply default rules to construct the chart when linked to a

Data control. These rules are somehow intelligent in picking the information

from the database and assign the legends to it, so if you send a SELECT

statement, Chart FX will create the chart series and point legends

automatically. These rules are:

'Series Legends will be taken from the numerical field names

'All numerical columns will be plotted as different series and all string

and/or date columns will be plotted as point legends (joined by the '-'

character).

'All string and numerical fields specified in the SELECT statement will be

plot.

'How to change the default behavior for databound charts?

'To change the data binding default behavior Chart FX contains properties

that allow you to change this method of plotting the data values. These

properties are only available and can be set at run time.

'Important Note:

'The DataStyle and Dtatype properties must be set before

'assigning the ADO resultset to the Chart FX Data Provider.

'DataStyle Property

'When having different string or date fields Chart FX will construct a

'long string with every string and date field to assign to every

'legend point in the chart. If you want to avoid this behavior just

'turn OFF the appropriate constants using the DataStyle property.

'For example, if you want to force Chart FX not to use field names as

'series legends and use date fields as point legends, you should use the

'DataStyle property as follows:

'ChartFX1.DataStyle = CHART_DS_USEDATEASLEG And Not CHART_DS_SERLEGEND

'DataType Property:

'Array property indicates the type of every field in the SELECT statement.

'This property is very useful when you want to control how Chart FX

'retrieves and display the information from the database.

'For example in a 5 field SELECT statement such as:

'"SELECT Year, Sales, Projected, Returns, Name FROM PRODSALES WHERE ProdID =

1234"

'The default behavior is that Chart FX will plot the year as another series

'since it is a number field and therefore it will be placed in the chart.

'Now, if the chart you want to make is one with the x axis containing the

year

'and plot the sales and projected sales in a different series without using

'the return and name fields you will fill the DataType array as follows:

'1st we have to convert year field in a string to be selected as a x axis

legend.

ChartFX1.DataType(0) = CDT_LABEL

'Then assigned the CDT_NUMBER constant to the numeric fields

ChartFX1.DataType(1) = CDT_VALUE

'ChartFX1.DataType(2) = CDT_VALUE

'Finally, assign CDT_NOTUSED to those fields we don't want to plot.

'ChartFX1.DataType(3) = CDT_NOTUSED

'ChartFX1.DataType(4) = CDT_NOTUSED

'Let Chart FX take information from the data provider

ChartFX1.GetExternalData CfxData

'Add any other adjustments to the object here.

'

'

ProcExit:

rs.Close

Conn.Close

Set Conn = Nothing

Set rs = Nothing

Set CfxData = Nothing

End Sub

Dan Hickman <dhickman@mediaone.net> wrote in message

news:nHv2sUXJAHA.1432@sfxserver.softwarefx.com...

> Hello everyone!

> Just found this forum and I am really excited to be here!

>

> I have an MS Access database with 2 different tables. From one of my

> tables, I need to make several different graphs from it using different

> queries. In other words, one table will produce 3-10 different graphs.

>

> I am currently using ADO within VB. I am a total newbie in development.

> How can I connect the chartfx to the ado and then change the recordset

from

> the different queries?

>

> I thank you in advance!

> Daniel Hickman

>

>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...