View Full Version : Is this possible?


NJudson
02-25-2002, 05:48 AM
I don't know if there is a way to do this but I have a form with a listbox which displays results of an SQL statement when I click my run query button. I then have my listbox with a double-click procedure attached to it which runs another SQL statement and displays the results of that in a different form. Here is my Double-Click statement:

Private Sub ListTotals_DblClick(Cancel As Integer)

Dim SWITCH As String

DoCmd.OpenForm "frmBreakOutDS", acFormDS
SWITCH = cboSwitch.Value

Forms!frmBreakOutDS.RecordSource = "SELECT [Totals].[Cell-ID], [Totals].[FBER Drop Attempts/Call Volume], " & _
"[Totals].[Digital Call-Volume], [Totals].[FBER-Drop-Attempts], " & _
"[Totals].[Switch], [Totals].[Date] " & _
"FROM Totals " & _
"WHERE [Totals].[Cell-ID] = '" & Me.ListTotals & "' " & _
"And [Totals].[Switch] = '" & SWITCH & "' " & _
"ORDER BY [Totals].[FBER Drop Attempts/Call Volume] DESC;"
Me.Refresh

End Sub

My question is these results that are outputed to this other form I want to be used to make a graph of chart(preferably just a line graph). If I use the chart wizard it only has the option to base it on a table or query. How can I make a chart or graph based on the SQL results that are displayed on my form.

1) First of all I have this SQL statements hardcoded because I have the user select a multitude of options on the original form(listbox form). And using standard queries would not be a viable option for what I'm doing.(at least this is the case with my limited knowledge of all this)

2) Is there a better way of running my Double-Click procedure to output the results from the 2nd SQL statement? Perhaps not to a form but something else which I can make into a graph.

3) Or can I somehow open and excel app and make a chart from that?

I'm not sure what the best way to do this is and would greatly appreciate any advice or direction on this. Thanks.

Alexandre
02-25-2002, 11:54 AM
1) Why don t you save you SQl to a temporary QueryDef?

Dim qryTempoQuery As QueryDef
Dim db As Database

Set db = DBEngine(0)(0)

db.CreateQueryDef ("Temporary_Query")
Set qryTempoQuery = db.QueryDefs("Temporary_Query")
qryTempoQuery.SQL = "Select TalbeA.* FROM TableA"
Set qryTempoQuery = Nothing
Set db = Nothing


2) In this case you wouldn t be obliged to display your query result on a form at all

3)Yes, you can, and you can also use directly the Excel OLE chart object from Access (withou using spreadsheets) and this is from far the best thing to do as soon as have more than basic flexibility and customization requirements for your charts.
Have a look to: http://www.vb123.com/toolshed/99_graphs/msgraph1.htm

Alex

[This message has been edited by Alexandre (edited 02-25-2002).]

NJudson
02-27-2002, 03:44 PM
Hey thanks. I was working toward something similar to that but wasn't getting the correct syntax and stuff down right. Much appreciated. Took me a while to catch your response because my boss, (once again) sent me off on another project. Seems like I keep getting stuff started but not much a chance to finish them. Oh well, such is life. http://www.access-programmers.co.uk/ubb/smile.gif