vba 如何在 Access 窗体中重新绘制 Microsoft 图表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5345799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Repaint Microsoft Chart in Access form
提问by MPelletier
I have a subformwhich sets the RowSource of a Microsoft Chart 5.0 object in its parentform.
我有一个子窗体,它在其父窗体中设置 Microsoft Chart 5.0 对象的 RowSource 。
EDIT: The Row Source Type for the graph is Value List.
编辑:图表的行源类型是值列表。
The graph does not paint itself, however, but any action which would generally generate a repaint (drag another Access window over it, minimize it, loss and regain of focus sometimes) does indeed repaint it. In other words, the graph doesn't show or change automatically.
然而,图形本身并不绘制,但任何通常会生成重绘的操作(在其上拖动另一个 Access 窗口,将其最小化,有时会丢失和重新获得焦点)确实会重绘它。换句话说,图表不会自动显示或更改。
How do I force a repaint of the chart after a subform action?
如何在子表单操作后强制重新绘制图表?
These have had no effect:
这些没有影响:
parent.Referesh
parent.Repaint
parent.TheChart.Refresh
And this does not seem to exist, unfortunately:
不幸的是,这似乎不存在:
parent.TheChart.Repaint
Using: Access 2003
使用:Access 2003
回答by Alex
The problem isn't the repainting of the graph. Most likely, the subform that you are using is retrieving data from a query or table.
问题不在于图形的重新绘制。最有可能的是,您使用的子表单正在从查询或表中检索数据。
You must update the values on the "datasource" object, which is providing the subform data (either a query or a table). Then, re-query the graph object in the mainform.
您必须更新“数据源”对象上的值,该对象提供子表单数据(查询或表)。然后,重新查询主窗体中的图形对象。
I made a very simple example in my MS-Acess 2000 and it worked great:
我在 MS-Acess 2000 中做了一个非常简单的例子,效果很好:
- A table (
t01_fruits
) with three columns (frt_id
,frt_name
,frt_qty
). - A subform based in the t01 table.
- A mainform with the previous subform inside, a pie-chart based on table
t01_fruits
and a button. In theOnClick
event of the button, I put justme.graph1.requery
.
- 一个表(
t01_fruits
)有三列(frt_id
,frt_name
,frt_qty
)。 - 基于 t01 表的子表单。
- 一个包含前一个子表单的主表单,一个基于表格
t01_fruits
和按钮的饼图。在OnClick
按钮的情况下,我只放了me.graph1.requery
.
When I update the fruits quantity in subform, inside mainform, nothing happens with the graph. When I click the button, the graph is updated correctly.
当我在主窗体中更新子窗体中的水果数量时,图形没有任何反应。当我单击按钮时,图形会正确更新。
回答by Arun Sharma
I also faced same problem in refreshing chart after updating information in form. I got it resolved by re-queering the chart after update of the inbox linking to change of data.
在更新表单中的信息后,我在刷新图表时也遇到了同样的问题。我通过在链接到数据更改的收件箱更新后重新排列图表来解决它。
Private Sub txtFinAgreeEnacDt_BeforeUpdate(Cancel As Integer)
Me.graphCRMStatus.Requery
end sub
Private Sub txtFinAgreeEnacDt_AfterUpdate()
Me.Requery
End Sub
Me is the Form holding graph....
我是Form持有图....
回答by Velid
I had similar problem like this, having main page with sub-forms, including 2 with graphs - and solution to refresh it was like this:
我有类似的问题,主页面带有子表单,包括 2 个带有图形的页面 - 刷新它的解决方案是这样的:
me.subForm.Requery
me.subForm!Graph1.Requery
Only when you execute commands in this order, it would update graph properly.
只有当你按照这个顺序执行命令时,它才会正确更新图形。
I know it's been a while since question was asked, but in case anyone else has issue like this.
我知道自从提出问题以来已经有一段时间了,但以防万一其他人遇到这样的问题。