How to reference control properties in Access

For example, I have a query that takes as a parameter the text property of the dropdown [DDB1] Form1. How can I refer to a property? My stumbling over Google showed that it must be something like Forms! [Form1]! [DDB1] .text But I could not find a definitive syntax for such links.

Any ideas?

Semi-OT - Access2003 help containing links to many Microsoft web pages returns many 404s when trying to load them. Is this just a coincidence? Or is the end of life hidden? '

+2


source to share


2 answers


To have a query link in a combo box on a form, use this syntax:

Forms!MyForm!MyComboBox

      

This will retrieve the selected property value

in the combo box (the value of the first column if it is a multi-column combo box).

If you want to select the value of another column in the combo box, this:

Forms!MyForm!MyComboBox.column(n)

      



Unlike most numeric indexes in VBA, n is zero (the second column is 1).

To reference a property text

, the combo box must have focus.

The help file appears to be suffering from link rot. Here are some links on MSDN for use:

Access 2003 Programming Reference
http://msdn.microsoft.com/en-us/library/aa167788(office.11).aspx

Access 2003 Language Reference
http://msdn.microsoft.com/en-us/library/aa663079(office.11).aspx

+3


source


You have several ways to access a control using MS-Access. In addition to @Robert Harvey's suggestion, you can also write:

forms(myFormName).controls(myControlName)

      

Despite what @Robert says, you can access all the properties of a control without setting focus. One important exception is the ".text" property, which refers to the text displayed in a control and where the focus should be on the corresponding control.



In most cases, the .text property is equal to the .value property, which can be accessed without setting focus on the control.

Thus, this property is only useful for controls like combobox or listbox where the associated column (which gives the .value property) is different from the displayed column (which gives the .text property).

+1


source







All Articles