Hi Colin, I've attached a sample version of the project I'm working on, along with the data.I’m not completely clear what you are doing. Can you upload a cut down version of your database to look at.
I didn't because I wasn't 100% sure on what you meant and you mentioned manually changing the color of the bars and this is what I want to avoid. I was also distracted by learning about modern charts so ended up going down that route.Did you attempt the method I suggested with creating multiple columns from a single field where one of the multiple will have the value and the others will return 0?
That's correct, Monday_Machine_Type_Usage_Total_StackedChartReport is the chart report and the chart is named Chart4.Just to check, the report shortcut is called Monday_Machine_Type_Usage_Total_StackedChartReport, the parameter dialog is
Finally the chart control is Chart4 ....
I think it will take me a while to work out how this all works and it may not be today. Perhaps others can look at it as well
My main objective was to have the blue progress bar coloured like the traffic light system, as you say.Two more questions to speed things up:
1. Am I right in thinking that all you are interested in is the blue progress bars on the stacked bar chart?
However, you would ideally like the progress bars to be the colour of the traffic light section where the bar ends.
2. The chart does appear to update as far as I can tell. Maybe I'm misunderstaning what you mean
For example, if I type in -35 I get the following:
but if I type in -21 I get
Similar changes occur for other parameter values
The two issues I have with this setup since using a modern chart:
If I can get the chart to requery, it should resolve my first issue as I can requery the chart after the report load event is complete.
- The chart in the report loads quicker than the report load event so [Text33] isn't populated with 0 (as per the report load event) before the underlying query for the chart can use this as its criteria.
- The chart isn't responding to the requery code I previously posted.
As I said, no rush. I do appreciate your time helping me with thisOK thanks. Can't do anything for now as I have a problem with my Office installation which I'm trying to resolve
Private Sub RequeryObjects()
Me.Monday_Production_Report.Requery
Me.Tuesday_Production_Report.Requery
Me.Tuesday_Machine_Availability_Subreport.Requery
Me.Wednesday_Production_Report.Requery
Me.Wednesday_Machine_Availability_Subreport.Requery
Me.Thursday_Production_Report.Requery
Me.Thursday_Machine_Availability_Subreport.Requery
Me.Friday_Production_Report.Requery
Me.Friday_Machine_Availability_Subreport.Requery
End Sub
Private Sub Command43_Click()
Me.Text33 = 0
RequeryObjects
End Sub
Private Sub Command36_Click()
If Me.Text33 = 0 Then
Me.Text33 = Me.Text39
Else
Me.Text33 =Me.Text42+Me.Text39
End If
Me.Text42 = Me.Text33
RequeryObjects
End Sub
Hi Colin,Hi Chris
Sorry but I can't see any way of applying conditional formatting based on the values of the percentage (blue) bars
i've just asked a member of the Access team if he can suggest a method of doing so and will let you know if I get a solution
As for the requerying, your chart is based on multiple layers of queries and it should be possible to simplify this considerably.
The chart should automatically update one the values are set using the various buttons.
You also have requery events for every single component of the report and report_load, after each button click and on a timer event.
I would also suggest simplifying all of those multiple layers of requery. You should be able to remove a lot of this code
I've spent well over an hour trying to simplify this but without success as far as the chart is concerned
Other things:
- Use Option Explicit at the top of all forms & reports and ensure all variables are declared
- You can shorten all the code by using Me. syntax e.g. Reports![Five_Day_Production_Report]![Monday_Production_Report].Report.Requery can be written as Me.Monday_Production_Report.Requery. Similarly for all the other similar lines
- You could also put all the requerí code lines into a separate procedure and call that as needed. For example:
Code:Private Sub RequeryObjects() Me.Monday_Production_Report.Requery Me.Tuesday_Production_Report.Requery Me.Tuesday_Machine_Availability_Subreport.Requery Me.Wednesday_Production_Report.Requery Me.Wednesday_Machine_Availability_Subreport.Requery Me.Thursday_Production_Report.Requery Me.Thursday_Machine_Availability_Subreport.Requery Me.Friday_Production_Report.Requery Me.Friday_Machine_Availability_Subreport.Requery End Sub
Now use that in your button click code which is far more complex than it needs to be
Code:Private Sub Command43_Click() Me.Text33 = 0 RequeryObjects End Sub Private Sub Command36_Click() If Me.Text33 = 0 Then Me.Text33 = Me.Text39 Else Me.Text33 =Me.Text42+Me.Text39 End If Me.Text42 = Me.Text33 RequeryObjects End Sub
4. Its very difficult to keep track of the controls as you are using default names such as Text33, Text42, Command36, Command37 etc
Use meaningful names e.g. cmdRefresh, cmdNext, cmdPrev etc.
The chart should automatically update one the values are set using the various buttons.
As I have said previously, the classic chart didn't have a problem with requerying using this setup. Why would this be different for a modern chart?I've spent well over an hour trying to simplify this but without success as far as the chart is concerned
Private Sub RequeryObjects()
Me.Monday_Production_Report.Requery
Me.Monday_Machine_Type_Usage_Total_StackedChartReport.Report.Chart4.RowSource = "Monday_Machine_Type_Usage_Chart_Query"
' Me.Monday_Machine_Type_Usage_Total_StackedChartReport.Report.Chart4.Requery 'REQUERY NOT NEEDED
Me.Tuesday_Production_Report.Requery
Me.Tuesday_Machine_Availability_Subreport.Requery
Me.Wednesday_Production_Report.Requery
Me.Wednesday_Machine_Availability_Subreport.Requery
Me.Thursday_Production_Report.Requery
Me.Thursday_Machine_Availability_Subreport.Requery
Me.Friday_Production_Report.Requery
Me.Friday_Machine_Availability_Subreport.Requery
End Sub
What doesn't compile?For info, it doesn't compile due to issues elsewhere in the FE
When I tested it failed on the Cutomer_Order_Form ... Goods_Out_Search_Button_Click on the lineWhat doesn't compile?
Category | RedValue | OrangeValue | GreenValue |
---|---|---|---|
Q1 | 30 | 20 | 50 |
Q2 | 10 | 40 | 100 |
Private Sub Form_Load()
Dim cht As Object
Set cht = Me.YourChartControl.Object
With cht
.SeriesCollection(1).Interior.Color = RGB(255, 0, 0) ' Red series
.SeriesCollection(2).Interior.Color = RGB(255, 165, 0) ' Orange series
.SeriesCollection(3).Interior.Color = RGB(0, 128, 0) ' Green series
End With
End Sub
All versions of Access including 365 are 'desktop versions'. There is no cloud edition of AccessAFAIK, Modern Charts upgrades are only available in Access 365, not desktop version.