无效使用Me关键字 [英] Invalid use of Me keyword

查看:178
本文介绍了无效使用Me关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码是一个函数,而不是私有子例程.我突然遇到Me.[这里的字段名称]错误.我没有在我的其他代码中得到这个错误,只是在这个代码中.这是我的完整代码,没有无聊的结尾部分,但是我从该行开始遇到了错误:

This code is a function and not a private subroutine. I'm suddenly getting this error with the Me.[field name here]. I'm not getting that error in my other code, just in this one. Here's my full code without the boring end part, but I'm getting the error starting from the line:

Me.assignedby.Column(1)

Public Function AssignNullProjects() As Long

    Dim db As dao.Database
    Dim rs As dao.Recordset
    Dim strSQL As String

    assignedby = TempVars("user").Value

    Set db = CurrentDb
    strSQL = "SELECT CFRRRID FROM CFRRR WHERE assignedto Is Null"
    Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
    If Not rs.BOF And Not rs.EOF Then
        While Not rs.EOF
            strSQL = "UPDATE CFRRR SET assignedto = " & GetNextAssignee & ", assignedby = " & Me.assignedby.Column(1) & ", Me.Dateassigned = #" & Now & "#, Me.actiondate = #" & Now & "#, Me.Workername = " & _
                              Me.assignedto.Column(0) & ", Me.WorkerID = " & Me.assignedto.Column(0) & " WHERE CFRRRID = " & rs!CFRRRID
            db.Execute strSQL, dbFailOnError
            rs.MoveNext
        Wend
    End If

    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

出现上述错误的可能原因是什么,如何将其消除?

What could be the possible reason for the above-stated error, and how it could be removed?

推荐答案

将该代码放入表单的代码模块中.当您尝试在标准模块中使用Me时,总是会收到该"Me关键字的无效使用" 投诉.

Put that code in the form's code module. When you try to use Me in a standard module, you will always get that "Invalid use of Me keyword" complaint.

在Access的帮助系统中查看无效使用Me关键字" "Me< keyword>" 主题以获取更多详细信息.

Check out the "Invalid use of Me keyword" and "Me <keyword>" topics in Access' help system for further details.

这篇关于无效使用Me关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆