简体   繁体   English

MS Access:子窗体中的未绑定字段未显示在报告中

[英]MS Access: Unbound fields in a subform not showing on a report

I'm having a bit of trouble figuring out how to fix an issue with my MS Access database report output. 我在弄清楚如何解决MS Access数据库报告输出问题时遇到了一些麻烦。

First: There are three forms, one of which is for navigation purposes (HOME) that has two navigation buttons in a navigation control (which link to either of the two other forms) and on subform field I use much like an iframe. 第一:共有三种形式,其中一种是出于导航目的(HOME),在导航控件中有两个导航按钮(它们链接到其他两种形式中的任何一种),在子表单域中,我使用的形式非常类似于iframe。 There are also two reports, one for each of the other forms. 也有两个报告,每个其他形式之一。

Second: Both forms have unbound text fields that need to be printed onto the report output. 第二:两种形式都有未绑定的文本字段,需要将其打印到报表输出上。 There is no need for these fields to be saved or put into a table. 无需将这些字段保存或放入表中。 The values of these forms are printed without issue when the form is isolated (ie- modal, form view, etc.). 隔离表格时 (即,模态,表格视图等) ,这些表格的值可以毫无问题地打印出来 The unbound fields are part of the main body of the form where controlled fields are located. 未绑定字段是受控字段所在的表单主体的一部分。

Only when a form is viewed in the "HOME" form in the subform box/iframe does the report show #Name? 仅当在子表单框/ iframe中的“ HOME”表单中查看表单时,报表才会显示#Name? instead of their intended values. 而不是其预期值。 Also worth noting, the subform does not have the Link Master Fields or Link Child Fields options. 另外值得一提的,子窗体没有 Link Master FieldsLink Child Fields选项。

The code used on the print command object/button is as follows and is located on the footer of the non-HOME forms: 打印命令对象/按钮上使用的代码如下,位于非HOME表单的页脚中:

Private Sub cmdPrint_Click()
    Dim strWhere As String

    If Me.NewRecord Then 'Check there is a record to print
        MsgBox "Select a record to print"
    Else
        strWhere = "[CustomerID] = " & Me.[CustomerID]
        DoCmd.OpenReport "TransferAgreement_EC", acViewPreview, , strWhere
    End If
End Sub

Any suggestions? 有什么建议么? I tried searching here and Googled the issue, but I haven't quite found the solution to my problem. 我尝试在此处搜索并用Google搜索问题,但尚未完全找到解决问题的方法。 Thanks in advance for your input! 预先感谢您的输入!

Okay. 好的。 So, found the solution by just running a whole lot of experiments and this fixed it. 因此,通过运行大量实验找到了解决方案,并对其进行了修复。

On the report itself, on the data field needs to call to both the navigation form and the subnavigation box, then point to the unbound field. 在报表本身上,在数据字段上需要同时调用导航表单和子导航框,然后指向未绑定字段。 For example, one field in the control source is: 例如,控制源中的一个字段是:

=[Forms]![Home]![NavigationSubform].[Form]![GCSerial_1]
  • Home = The navigation form 主页=导航表单
  • NavigationSubform = The nagivation subform box (what I consider an "iframe") NavigationSubform =导航子表单框(我认为是“ iframe”)
  • Form = Just a call to to a form, not specific 表格=只是对表格的调用,不具体
  • GCSerial_1 = The unbound text field GCSerial_1 =未绑定的文本字段

In this way, the report will not print the unbound fields when it is not a subform of the navigation form. 这样,当报表不是导航表单的子表单时,报表将不会打印未绑定的字段。 For example, by default my two other forms are modal pop ups. 例如,默认情况下,我的其他两种形式是模式弹出窗口。 When I "form view" them as modal prompts, the unbound fields display #Name? 当我将它们“表单视图”作为模式提示时,未绑定的字段显示#Name? when I click my print command button, which specifies a report (no longer) contingent on a subform and not an isolated form. 当我单击我的打印命令按钮时,该按钮指定(不再)取决于子表单而不是孤立表单的报告。

THANKS FOR THE HELP AND INSPIRATION! 感谢您的帮助和启发! <3 <3

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

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