无法引用属性或方法/类型不匹配 Microsoft Access

Posted

技术标签:

【中文标题】无法引用属性或方法/类型不匹配 Microsoft Access【英文标题】:Can't reference a property or method/Type Mismatch Microsoft Access 【发布时间】:2020-07-23 14:27:58 【问题描述】:

我正在为我的公司建立一个数据库,但我不知道为什么会出现这些错误。

我正在将数据从子表单 (trailfrm) 传输到父表单 (AD/Sieve Data),并对未绑定的字段进行数学运算以获得存储的最终值。我需要在当前清除 AD/Sieve 数据上的这些字段,并且我已经编写了代码来做到这一点,但是当我尝试在 trailfrm 上运行代码时,它要么说它不能引用属性、方法或类型不匹配。如果我将文本框引用为 xxx.text,它表示它不能引用控件的属性或方法,除非控件具有焦点。如果我有 xxx.value,它的类型不匹配。我尝试将焦点设置为 AD/Sieve Data,但没有帮助。我是一名新手程序员,所以这就是我对故障排除的了解程度。

我的 trailfrm 代码是:

Private Sub Command574_Click()


Dim rs As DAO.Recordset

Set rs = Me.Recordset
With rs
 .MoveFirst
 Do While Not .EOF
    .Edit
    If Me.Combo331.Value = "Lot" And Me.[Sample].Value = "1" And Me.Text575.Value = Forms![AD/Sieve Data]!Text1699.Value Then Forms![AD/Sieve Data]!Text1598.Value = Me.DC.Value
    If Me.Combo331.Value = "Lot" And Me.[Sample].Value = "2" And Me.Text575.Value = Forms![AD/Sieve Data]!Text1699.Value Then Forms![AD/Sieve Data]!Text1600.Value = Me.DC.Value
    If Me.Combo331.Value = "Lot" And Me.[Sample].Value = "3" And Me.Text575.Value = Forms![AD/Sieve Data]!Text1699.Value Then Forms![AD/Sieve Data]!Text1613.Value = Me.DC.Value
    If IsNull(Forms![AD/Sieve Data]!Text1613.Value) Then Forms![AD/Sieve Data]!Text1602.Value = (Forms![AD/Sieve Data]!Text1598.Value + Forms![AD/Sieve Data]!Text1600.Value) / 2
    *** [Debug points to this line] *** If Not IsNull(Forms![AD/Sieve Data]!Text1613.Value) Then Forms![AD/Sieve Data]!Text1602.Value = (Forms![AD/Sieve Data]!Text1598.Value + Forms![AD/Sieve Data]!Text1600.Value + Forms![AD/Sieve Data]!Text1613.Value) / 3
    
    
    [Insert very similar, extensive math code here]
    
    On Error Resume Next
    
   

    .Update
    .MoveNext
 Loop
End With
Set rs = Nothing

End Sub

我的 AD/筛子数据代码是:

Private Sub Form_Current()
Me.Text1578.Enabled = True
If Check1927.Value = False Then
Forms![AD/Sieve Data]!Trailfrm.Form!Text644.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text646.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text648.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text650.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text652.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text704.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text654.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Label703.Visible = False
Forms![AD/Sieve Data]!Text2013.Visible = False
Forms![AD/Sieve Data]!Text2015.Visible = False
Forms![AD/Sieve Data]!Text1950.Visible = False
Forms![AD/Sieve Data]!Text2023.Visible = False
Forms![AD/Sieve Data]!Text2025.Visible = False
Forms![AD/Sieve Data]!Text1974.Visible = False
Forms![AD/Sieve Data]!Label1951.Visible = False
Forms![AD/Sieve Data]!Label1975.Visible = False
Forms![AD/Sieve Data]!Label1836.Visible = False
Forms![AD/Sieve Data]!Text1835.Visible = False
End If
If Check1927.Value = True Then
Forms![AD/Sieve Data]!Trailfrm.Form!Text644.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text646.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text650.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text648.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text652.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text704.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text654.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Label703.Visible = True
Forms![AD/Sieve Data]!Text2013.Visible = True
Forms![AD/Sieve Data]!Text2015.Visible = True
Forms![AD/Sieve Data]!Text1950.Visible = True
Forms![AD/Sieve Data]!Text2023.Visible = True
Forms![AD/Sieve Data]!Text2025.Visible = True
Forms![AD/Sieve Data]!Text1974.Visible = True
Forms![AD/Sieve Data]!Label1951.Visible = True
Forms![AD/Sieve Data]!Label1975.Visible = True
Forms![AD/Sieve Data]!Label1836.Visible = True
Forms![AD/Sieve Data]!Text1835.Visible = True
End If

*** [This block of code causes the error] ***
Forms![AD/Sieve Data]!Text1598.Value = ""
Forms![AD/Sieve Data]!Text1600.Value = ""
Forms![AD/Sieve Data]!Text1613.Value = ""
Forms![AD/Sieve Data]!Text1175.Value = ""
Forms![AD/Sieve Data]!Text1179.Value = ""
Forms![AD/Sieve Data]!Text1183.Value = ""
Forms![AD/Sieve Data]!Text1250.Value = ""
Forms![AD/Sieve Data]!Text1248.Value = ""
Forms![AD/Sieve Data]!Text1187.Value = ""
Forms![AD/Sieve Data]!Text1378.Value = ""
Forms![AD/Sieve Data]!Text1380.Value = ""
Forms![AD/Sieve Data]!Text1382.Value = ""
Forms![AD/Sieve Data]!Text1387.Value = ""
Forms![AD/Sieve Data]!Text1389.Value = ""
Forms![AD/Sieve Data]!Text1391.Value = ""
Forms![AD/Sieve Data]!Text1523.Value = ""
Forms![AD/Sieve Data]!Text1525.Value = ""
Forms![AD/Sieve Data]!Text1526.Value = ""
Forms![AD/Sieve Data]!Text1929.Value = ""
Forms![AD/Sieve Data]!Text1931.Value = ""
Forms![AD/Sieve Data]!Text1933.Value = ""
Forms![AD/Sieve Data]!Text2013.Value = ""
Forms![AD/Sieve Data]!Text2015.Value = ""
Forms![AD/Sieve Data]!Text2023.Value = ""
Forms![AD/Sieve Data]!Text2025.Value = ""


End Sub

截图:Here

【问题讨论】:

【参考方案1】:

可能不允许使用空字符串,因此请尝试使用 Null

Forms![AD/Sieve Data]!Text1598.Value = Null

【讨论】:

以上是关于无法引用属性或方法/类型不匹配 Microsoft Access的主要内容,如果未能解决你的问题,请参考以下文章

命名空间“Microsoft”中不存在类型或命名空间名“Reporting”(是否缺少程序集引用?)

Xcode 6.1:发现多个名为“count”的方法,结果、参数类型或属性不匹配

命名空间“Microsoft”中不存在类型或命名空间名称“AspNetCore”(您是不是缺少程序集引用?)

发现多个名为“edges”的方法,结果、参数类型或属性不匹配

“Microsoft”中不存在类型或命名空间名称“Office”(是否缺少程序集引用?)

错误 CS0234:命名空间“Microsoft”中不存在类型或命名空间名称“AspNetCore”(您是不是缺少程序集引用?)