VbA访问编译:找不到方法或数据成员



我有这个代码在VBA:

Private Sub cmdAdd_Click()
    'when we click on button Add there are two options
    '1. for insert
    '2. for update
    If Me.Barcode & "" = "" Then
        'this is for insert new
        'add data to table
        CurrentDb.Execute "INSERT INTO tab_barcodeki([date], [time], category, barcode) " & _
                " VALUES(" & Me.Date & ",'" & Me.Time & "','" & _
                Me.Category & "','" & Me.Barcode & "')"
    Else
        'otherwise (Tag of barcode store the id of liquid to be modified)
        CurrentDb.Execute "UPDATE tab_barcodeki " & _
                " SET [date]=" & Me.Date & _
                ", [time]='" & Me.Time & "'" & _
                ", category='" & Me.Category & "'" & _
                ", barcode='" & Me.Barcode & "'" & _
                " WHERE barcode=" & Me.Barcode.Tag
    End If
    'clear form
    cmdClear_Click
    'refresh data in list on form
    tab_barcodekisubform.Form.Requery
End Sub

当我编译时,我有编译错误,方法或数据成员找不到。我已经检查了表格列和文本框的名称,文本框链接是相同的。你有什么解决办法吗?

谢谢

Me!Date代替Me.Date

适用于Me.Date, Me.Time, Me.Barcode, Me.Category

Me!Barcode.Tag代替Me.Barcode.Tag

您可以使用.只引用真正的属性。所以Me.Date期望表单具有Date属性-它没有,所以你得到错误。当引用表单成员的名称时,使用!而不是dot。

最新更新