简体   繁体   English

如何在MS Access子窗体上引用图表对象?

[英]How to reference a chart object on an MS Access subform?

I have created a dozen different charts using the chart form wizard in Access (so each chart is really a separate form). 我使用Access中的图表表单向导创建了十几个不同的图表(因此每个图表实际上是一个单独的表单)。 I have also set up a GUI that has the following nested form structure: 我还设置了一个具有以下嵌套表单结构的GUI:

frmMain -> frmSubMain -> Child0 (a subform of frmSubMain)

I have a list box on frmSubMain that lists all the charts, and when a user selects one, I use VBA to change the Source Object of Child0 to the appropriate form for the selected chart. 我在frmSubMain上有一个列出所有图表的列表框,当用户选择一个时,我使用VBA将Child0的源对象更改为所选图表的相应表格。 (So in essence, a user can select the desired chart and it is presented.) (因此,实际上,用户可以选择所需的图表并显示它。)

I am now trying to add a button to frmSubMain that will copy the currently selected chart to PowerPoint, but I am having trouble with the copy command and referencing the chart object. 我现在正在尝试向frmSubMain添加一个按钮,该按钮将当前选定的图表复制到PowerPoint,但我在复制命令和引用图表对象时遇到问题。 The chart object on each of the forms is called OLEUnbound0, and here is what I've tried (I have the form name for the chart as a variable 'my_form'): 每个表单上的图表对象称为OLEUnbound0,这是我尝试过的(我将图表的表单名称作为变量'my_form'):

  • Forms(my_form).OLEUnbound0.acOLECopy 表格(my_form).OLEUnbound0.acOLECopy
  • Me.Child0.OLEUnbound0.acOLECopy Me.Child0.OLEUnbound0.acOLECopy
  • Me.Controls(my_form).OLEUnbound0.acOLECopy Me.Controls(my_form).OLEUnbound0.acOLECopy

Each gives a different error (for example, the second one gives the error "Method or data member not found"). 每个都给出了不同的错误(例如,第二个给出错误“未找到方法或数据成员”)。 Part of my confusion is that I have the form name but as a variable, and I'm not sure how to use that variable (since I can't use the standard Forms![frmMain]![frmSubMain]! etc.). 我的一部分困惑是我有表单名称但作为变量,我不知道如何使用该变量(因为我不能使用标准表单![frmMain]![frmSubMain]!等)。 What is the syntax for using a variable to reference a subform? 使用变量引用子表单的语法是什么?

尝试:

Me.Child0.Form.OLEUnbound0.Action = acOLECopy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM