The method we used to descend from orbit to the surface of an alien world worked, but it would have been far more efficient and far less traumatic if we could just beam down.
Please not this technique is using a Deprecated method so may not work. Info
It would be useful to have completed the Access course first. I will assume this and not go through it.
We are going to use the sample PCResale.NET Db from the Access Courses.
'https://developers.google.com/chart/image/docs/chart_params#gcharts_chs
chtt=<chart_title>
chts=<color>,<font_size>,<opt_alignment>
chs=<width>x<height>
chf=<fill_type>,s,<color>
cht=<chart_type>
chd=t:s,e,r,i,e,s,1|s,e,r,i,e,s,2|... OR s:series1,series2,... OR e:series1,series2,...
chl=<label>|...
Final
<script language="vbscript">
' Connection String
Dim sConnect
'Commands
Dim objCmdPC 'Pie Chart
'RecordSets
Dim objRSPC
'Initialize Connection String to connect to an MS Access Database
sConnect = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=PCResale.accdb;
Persist Security Info=False"
Sub CreateChart()
'Create a command object to execute Advancded SQL Statements
Set objCmdPC = CreateObject("ADODB.Command")
objCmdPC.ActiveConnection = sConnect 'Connect to database
' Total Number Customers in a Company
objCmdPC.CommandText = "SELECT CustomerT.CompanyName,
Count(CustomerT.CompanyName) AS CountOfCompanyName
FROM CustomerT GROUP BY CustomerT.CompanyName;"
' Create the actual recordset to be used in this script
' and retrieve or display information from database
Set objRSPC = CreateObject("ADODB.Recordset")
Set objRSPC = objCmdPC.Execute
Dim strPC
Dim chartTitle
Dim chartValues
Dim chartLabels
Dim chartColours
Dim chtType
Dim n
For n = 0 to Document.Charts.chtType.length - 1
If Document.Charts.chtType(n).checked Then
chtType = Document.Charts.chtType(n).Value
End If
Next
While Not objRSPC.EOF
chartLabels = chartLabels & objRSPC("CompanyName") &_
" (" & objRSPC("CountOfCompanyName") & ")" & "|"
chartValues = chartValues & objRSPC("CountOfCompanyName") & ","
objRSPC.MoveNext
Wend
chartLabels = Left(chartLabels, len(chartLabels)-1)
chartValues = Left(chartValues, len(chartValues)-1)
chartTitle = "Number of Customers in a Company"
'https://developers.google.com/chart/image/docs/chart_params#gcharts_chs
'chtt=<chart_title>
'chts=<color>,<font_size>,<opt_alignment>
'chs=<width>x<height>
'chf=<fill_type>,s,<color>
'cht=<chart_type>
'chd=t:s,e,r,i,e,s,1|s,e,r,i,e,s,2|... OR s:series1,series2,... OR e:series1,series2,...
'chl=<label>|...
strPC = "<img src='http://chart.apis.google.com/chart?" &_
"chtt=" & chartTitle & "&" &_
"chts=000000,12&" &_
"chs=450x150&" &_
"chf=bg,s,ffffff&" &_
"cht=" & chtType & "&" &_
"chd=t:" & chartValues & "&" &_
"chl=" & chartLabels & "&" &_
"chco=FFCC00,33CC00,3333FF,CC0000' " &_
"alt='" & chartTitle & "'/>"
'msgbox strPC
document.Charts.source.value = strPC
myContent.innerHTML = strPC
'Clean Up and Close
objRSPC.Close
Set objRSPC = Nothing
End Sub
</script>