As you add controls, or even when you name fields, there are a few things to keep in mind that make the process of creating queries, forms, and reports much easier. The first is to avoid the use of spaces or punctuation in field and control names. Spaces may make your field names easier to read, but they are not user-friendly when it comes to queries or code. Consider a field named Last Name with a space in the middle. This field name must be bracketed when used in a query. Without the space, brackets are not required. It turns out that brackets are also required when you refer to the field in code, so instead of referring to the field like this:
Me!LastName you must refer to it like this:
As you can see, using the space in the name makes it harder to read and write in code. Instead, don't use spaces in names; use the Caption property of a field or label control to change the displayed text.
Another issue that causes problems is circular references. A circular reference occurs when a control uses itself in an expression. Say, for example, you drag a field named LastName to a report, and then decide to change the ControlSource property for the control to:
Unless you rename this control, the LastName control will try to use LastName in the expression, which is itself an expression — in other words, a circular reference. To avoid circular references, be sure to rename the control when you modify the ControlSource. In this example, you might consider renaming LastName to txtLastName.
Was this article helpful?