Not a stupid question at all. It's not intuitive at all.
The Me prefix followed by a dot (Me.) in a form's code module (the collection
of code used by the form) means that what follows is a property of the form.
Controls (text boxes, combo boxes, lines, and pretty much anything you can
put on the form) are considered properties of the form, as are things such as
AllowEdits, Recordsource, and quite a few others. If you set the form's
Allow Edits property to False on the form's Property sheet, you can have code
in a command button to set it to True. The command button Click event would
have:
Me.AllowEdits = True
Or you could change the record source:
Me.Recordsource = "QueryName"
The command button code is in the form's code module, so the Me prefix tells
Access to allow edits for the form to which the code module belongs. It does
not affect AllowEdits in any other forms.
If you use the Me prefix followed by a text box name, what follows is a
property of the text box. If you type Me. you should see a list of
properties including RecordSource, but not ControlSource. After the text box
name and a dot you will see ControlSource, but not RecordSource. A form has
a Record Source but not a Control Source; vice versa for a control. The
following code (in a command button Click event, for instance) will set the
Control Source of the text box Text1 to the field Comments, which we will
assume is in the form's Record Source table or query:
Me.Text1.ControlSource = "Comments"
As another example, you can hide Text1:
Me.Text1.Visible = False
There is more, depending on the details of what you are doing, but I will
mention a few things. Access Help shows Me! rather than Me. in some examples.
Generally, you can use the dot rather than the bang (!). I won't try to get
into the subtleties of that just now, but can direct you to an article on the
topic if you are interested.
Using the dot produces a list of choices. I have heard this referred to as
the Intellisense menu. The bang does not produce the menu. The menu
contains properties of the form, but also user-defined functions and some
Methods such as Requery. I have to admit I don't know why some Methods are
listed and others are not.
In many cases you do not absolutely need to use the Me prefix, but if you do
not, Access has to sort out whether you are referring to a variable, property,
method, control, or whatever. The Me prefix narrows the list, and should
make the code run faster, although often the difference will be minor.
Thanks Bruce, that helped heaps.
Stupid question, having a blonde moment what is Me???
Ness
The code you have written assumes a combo box Row Source of at least four
columns, with numbers in the second, third, and fourth columns. The first
[quoted text clipped - 71 lines]