Invalid Reference to Rowsource??

Milothicus

Registered User.
Local time
Today, 23:12
Joined
Sep 24, 2004
Messages
134
I've got a report that includes a pie chart created through the chart wizard. the source data for the chart depends on options set in a form. to change the source data, (in the OnOpen event), i create an SQL string and then i have the following line:

me.objGraph.rowsource = SQL

once the code gets to this line, it breaks, and i get runtime error 2455a; You entered an expression that has an invalid reference to the property RowSource.

i press F8, and it works. it just won't work on the first try.

any ideas?
 
anyone have a work-around idea? the error handler doesn't seem to catch it either.

oops, just saw that the error number is 2455, not 2455a.

it looks to me like these chart objects aren't very well linked with access. everything seems a little.....questionable...
 
Well, what's SQL?
 
SQL is a valid SQL string....

SQL = "SELECT qryRpt." & Forms!frmjbbkrpts.Form!cboFctr & " as [Medium], Sum(qryRpt.RevValue) AS [SumOfRevValue], Avg(qryRpt.RevValue) AS [AvgOfRevValue]," & _
" Count(qryRpt.Enquiry_Index) AS [CountOfEnquiry_Index] FROM qryRpt GROUP BY qryRpt." & Forms!frmjbbkrpts.Form!cboFctr

which when evaluated returns:

SELECT qryRpt.Medium as [Medium], Sum(qryRpt.RevValue) AS [SumOfRevValue], Avg(qryRpt.RevValue) AS [AvgOfRevValue], Count(qryRpt.Enquiry_Index) AS [CountOfEnquiry_Index] FROM qryRpt GROUP BY qryRpt.Medium

...

i'm wondering if somethings wrong with my installation of VB or access. I just noticed that this module is ignoring the 'on error goto' line, like the one i posted about in the forms forum, but this shouldn't be an error at all.

also, the error wording leads me to believe that the problem isn't an invalid SQL string, but with referring to the rowsource of my chart. Im stuck...
 
http://www.access-programmers.co.uk/forums/showthread.php?t=87612

ok, my mistake. changed options to break on all errors. if i break only on unhandled errors, and use the following code:

Code:
SQL = "SELECT qryRpt." & Forms!frmjbbkrpts.Form!cboFctr & " as [Medium], Sum(qryRpt.RevValue) AS [SumOfRevValue], Avg(qryRpt.RevValue) AS [AvgOfRevValue]," & _
   " Count(qryRpt.Enquiry_Index) AS [CountOfEnquiry_Index] FROM qryRpt GROUP BY qryRpt." & Forms!frmjbbkrpts.Form!cboFctr
TryAgain:
   Debug.Print SQL
   Me.objGraph.RowSourceType = "Table/Query"
   Me.objGraph.RowSource = SQL
   
   SQL = "SELECT qryRpt." & Forms!frmjbbkrpts.Form!cboFctr & " as [Factor], Sum(qryRpt.RevValue) AS [Total Value], Avg(qryRpt.RevValue) AS [Average Value]," & _
   " Count(qryRpt.Enquiry_Index) AS [Number of Jobs] FROM qryRpt GROUP BY qryRpt." & Forms!frmjbbkrpts.Form!cboFctr & _
   " ORDER BY Sum(qryRpt.RevValue)"
   Me.lstValues.RowSource = SQL
   Exit Sub
FErrorHandler:
      Resume Next
      If Err.Number = 2455 Then
         Err.Clear
         GoTo TryAgain
      End If

that particular error just causes it to 'try again' and now it works. not the most reliable solution, but it works...
 

Users who are viewing this thread

Back
Top Bottom