【问题标题】:Show on Main form the value of a Text box on sub form在主窗体上显示子窗体上的文本框的值
【发布时间】:2016-01-15 20:53:27
【问题描述】:

我有一个子表单(连续表单),它在子表单页脚的文本框中显示费用的总和:

Text5 data =Sum(Fee). 

这可以正常工作。我不能做的是在主窗体的另一个文本框中显示该值。我试过了

TFees = Forms!frmInvoice![frmInvoiceDetails].Form.Text5

这在 main from 上没有显示任何内容(Null?)。没有错误。我的子表单数据是:

SELECT 
    tblInvoiceDetails.InvoiceLookup, 
    tblInvoiceDetails.DiscLookup, 
    [ApplicantSurname] & ', ' & [ApplicantForenames] AS AppName, 
    [DBSFee]+[MyFee] AS Fee, 
    tblDisclosure.Client, 
    tblDisclosure.Payer 
FROM 
    tblInvoiceDetails 
INNER JOIN 
    tblDisclosure 
    ON tblInvoiceDetails.DiscLookup = tblDisclosure.ID 
WHERE 
    (((tblDisclosure.Payer)='Client')) 
ORDER BY 
    [ApplicantSurname] & ', ' & [ApplicantForenames]; 

【问题讨论】:

    标签: ms-access vba


    【解决方案1】:

    试试:

    =Forms!frmInvoice!NameOfYourSubformControl.Form!Text5
    

    将“NameOfYourSubformControl”替换为该名称,而不是表单的名称。

    【讨论】:

    • 它的名字是 frmInvoiceDetails。 TFees = Forms!frmInvoice!frmInvoiceDetails.Form!Text5 给出的结果是 0.00,无论子表单上出现什么值。 TFees = Sum(Forms!frmInvoice!frmInvoiceDetails.Form!Fee) 给出错误消息“未定义子或函数”。
    • 表达式用于ControlSource,不用于代码。
    • = Forms!frmInvoice!frmInvoiceDetails.Form!Text5 有效。非常感谢。这就是答案。
    【解决方案2】:

    试试:

    TFees.value = Forms("frmInvoiceDetails").Text5.value
    

    【讨论】:

    • 什么样的错误?另一种选择是将“.value”添加到代码中的两个文本框名称。
    • #Error 是 TFees 文本框中显示的内容 - 当我将“值”添加到两个文本框名称时。
    • 主窗体上的文本框名称为Text14。控制源 =TFees()。公共函数 TFees() As Variant TFees.Value = Forms("frmInvoiceDetails").Text5.Value 结束函数
    猜你喜欢
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-27
    • 1970-01-01
    • 2021-03-03
    相关资源
    最近更新 更多