[SOLVED] Customised chart built by Function: Report vs SubReport Problem
OK so I've always been very disappointed with the limited capabilities of Charting in Access, so major review time for my database why not try and build a common function to build a customised chart (graph) for my report.
There's a very strong chance i've done a lot of this wrong, so very willing to take advice.
My current issue is this: I've actually got this working quite nicely when using the report or form as a standalone report or a standalone form. (see attached).
So i kinda cheated, not knowing how, or finding a guide to assist me in "Creating" the shape,line,label elements, i pre-loaded enough of each element to be sure to cover what i need, named them all with increasing integer; eg (lnMin0, lnMin1.....lnMin100) represents 101 minor gridlines just as (lnMaj0, lnMaj1.....lnMaj20) represents 21 major gridlines.
Once the chart parameters are fed to the function from the Call() procedure relevant scales and ratings parameters are retrieved from several tables, which are then used to alter the .pos .height .width .visible .caption parameters of each shape through a series of loops.
One image shows the report open in design mode with all the pre-loaded shape elements in no particular arrangement, the second shows the loaded form successfully displayed (except some of mu debugging ctrl's).
So to my current problem:
This is the method used in the function to set the caption parameter for the shape lblRSunits (which is a label) (outName = string referring to the report name "rptSub_RHR".
This piece of code works great for the report as a standalone, but when i add the report as a subreport to another main report i get the following error:
"The report name 'rptSub_RHR' you enterd is misspelled or refers to a report that isn't open or doesn't exist."
I'm assuming the Report() is now referring to the Main Report "rptBHA_2015" and not the oeiginal report which is now the SubReport.
I'm hurting now because the following code works to send a value to a control, now using both a reference to the report name (outName) and to the subreport (outSubName).
But a similarly structured line to alter the caption of a label doesn't work.
Very sorry for the long winded explanation/question, any assistance very welcome.
Cheers
Nathan
OK so turns out i've partially solved my initial problem.
It seems that the 'Method' of referencing the controls on the report needs to be standardised, that is, it would appear that the Me.frm... or the Forms!frmName!subfrmName... method is not available for referring to controls from a function/module.
And it appears that the controls method of referencing needs to follow through all the way to the point of the 'Properties'. The following code works, i simply had to Dim a string value to represent each of the forms, subforms, reports, subreports and controls.
outName = MainFormName OR MainReportName
outSubName = SubFormName OR SubReportName
ctrl01 = NameOfControl (named the same whether on the form or the report).
I simply set an If statement to detect if i was using a form or a report to determine which of the commands to use.
Now however, when loading the report/subreport i often have to actually click on the report for it to appear, (no code errors), and is simply cannot get any of the details to print...
Will add a separate thread to request assistance with this one
Off to fight the next code battle...
OK so I've always been very disappointed with the limited capabilities of Charting in Access, so major review time for my database why not try and build a common function to build a customised chart (graph) for my report.
There's a very strong chance i've done a lot of this wrong, so very willing to take advice.
My current issue is this: I've actually got this working quite nicely when using the report or form as a standalone report or a standalone form. (see attached).
So i kinda cheated, not knowing how, or finding a guide to assist me in "Creating" the shape,line,label elements, i pre-loaded enough of each element to be sure to cover what i need, named them all with increasing integer; eg (lnMin0, lnMin1.....lnMin100) represents 101 minor gridlines just as (lnMaj0, lnMaj1.....lnMaj20) represents 21 major gridlines.
Once the chart parameters are fed to the function from the Call() procedure relevant scales and ratings parameters are retrieved from several tables, which are then used to alter the .pos .height .width .visible .caption parameters of each shape through a series of loops.
One image shows the report open in design mode with all the pre-loaded shape elements in no particular arrangement, the second shows the loaded form successfully displayed (except some of mu debugging ctrl's).
So to my current problem:
Code:
Reports(outName).lblRSunits.Caption = RSunits
This is the method used in the function to set the caption parameter for the shape lblRSunits (which is a label) (outName = string referring to the report name "rptSub_RHR".
This piece of code works great for the report as a standalone, but when i add the report as a subreport to another main report i get the following error:
"The report name 'rptSub_RHR' you enterd is misspelled or refers to a report that isn't open or doesn't exist."
I'm assuming the Report() is now referring to the Main Report "rptBHA_2015" and not the oeiginal report which is now the SubReport.
I'm hurting now because the following code works to send a value to a control, now using both a reference to the report name (outName) and to the subreport (outSubName).
Code:
Reports(outName)(outSubName)(txtCtrl8).value = outName
Code:
Reports(outName)(outSubName).lblRSunits.Caption = RSunits
Very sorry for the long winded explanation/question, any assistance very welcome.
Cheers
Nathan
OK so turns out i've partially solved my initial problem.
It seems that the 'Method' of referencing the controls on the report needs to be standardised, that is, it would appear that the Me.frm... or the Forms!frmName!subfrmName... method is not available for referring to controls from a function/module.
And it appears that the controls method of referencing needs to follow through all the way to the point of the 'Properties'. The following code works, i simply had to Dim a string value to represent each of the forms, subforms, reports, subreports and controls.
Code:
Forms(outName)(outSubName)(ctrl01).Caption = "strValue"
Reports(outName)(outSubName)(ctrl01).Caption = "strValue"
outSubName = SubFormName OR SubReportName
ctrl01 = NameOfControl (named the same whether on the form or the report).
I simply set an If statement to detect if i was using a form or a report to determine which of the commands to use.
Now however, when loading the report/subreport i often have to actually click on the report for it to appear, (no code errors), and is simply cannot get any of the details to print...
Will add a separate thread to request assistance with this one
Off to fight the next code battle...
Attachments
Last edited: