As an example, to refer to a control on a form, the code might look something like this:
Me.ControlNameThat's basically the same as the following:
Forms!FormName.ControlNameSo, the question is then, when should or could you use "Me" in your code?
As I mentioned earlier, "Me" is a shortcut way to refer to the current object. So, if you're code is executing behind a form or report and you want to refer to the controls or properties of that object, you can use "Me" in your code. If, however, your code is executing within a Standard Module, then using "Me" would be inappropriate, i.e. it will not work. If that's the case, you can either pass a form object to your code or use the forms collection syntax (e.g. Forms!FormName) to refer to form controls and properties.
One other very important thing to remember is that "Me" is a VBA-only construct. In other words, you cannot use "Me" in queries or macros. It cannot even be used in the Control Source on forms and reports. For example, using the following as control source in a textbox will result in an error:
=Me![FieldName]To get around that, Access allows us to use the "Form" keyword. So, to fix the error, the above would have to be written as follows:
=[Form]![FieldName]Unfortunately, for queries and macros, your only choice is to use absolute referencing using the Forms!FormName syntax.
Original post date: April 30, 2015