ACC2000: Column Properties in Query May Disappear After You Run DAO Code or a Wizard
ID: Q247488
|
The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
SYMPTOMS
The user-defined properties that you set for all columns in a query may be deleted. If you are using Data Access Objects (DAO) code, the query does not return a value for the properties or uses the properties from the table that the query is based on.
You may also receive one or more of the following error messages when you run the query:
Invalid operation.
-or-
Property can be set only when the Field is part of a Recordset object's Fields collection.
-or-
Operation is not supported for this type of object.
-or-
Property not found.
CAUSE
This problem can occur when you have Name AutoCorrect enabled, and you do one of the following:
- You use a wizard to create a query, form, report, or data access page that is based on the query with user-defined properties.
-or-
- You run DAO code that uses the properties of a column in a query with user-defined properties.
RESOLUTION
Open the query in Design view and reenter the properties.
To avoid this behavior, make the Name AutoCorrect command unavailable. To do so, follow these steps:
- On the Tools menu, click Options.
- In the Options dialog box, click the General tab.
- Click to clear the Track name AutoCorrect info check box.
- Click OK.
- Quit, and then restart Access.
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed
at the beginning of this article.
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new database and import the Customers table from the sample database Northwind.mdb.
- Create a query based on the Customers table.
- Add the CustomerID and the CompanyName fields to the query.
- Right-click the CustomerID field in the query, and then click Properties.
- Type a text description in the Description box of the Field Properties dialog box.
- Save the query as Query1, and then close it.
- Reopen the query in Design view to confirm that the description is still there.
- Close the query.
-
In the Immediate window, run the following code that displays the property name and value of the CustomerID field.
NOTE: The sample code in this article uses Microsoft Data Access
Objects. For this code to run properly, you need to reference
the Microsoft DAO 3.6 Object Library.
Sub GetFieldDescription()
Dim DB As DAO.Database
Dim QD As DAO.QueryDef
Dim Fld As DAO.Field
Dim prp As DAO.Property
On Error GoTo err_GetFieldDescription
Set DB = CurrentDb
Set QD = DB.QueryDefs("Query1")
Set Fld = QD.Fields("CustomerID")
For Each prp In Fld.Properties
Debug.Print prp.Name, prp.Value
Next
Exit Sub
err_GetFieldDescription:
If Err.Number = 3251 Then
Debug.Print Err.Number, Err.Description
Resume Next
ElseIf Err.Number = 3219 Then
Debug.Print Err.Number, Err.Description
Resume Next
ElseIf Err.Number = 3267 Then
Debug.Print Err.Number, Err.Description
Resume Next
Else
Debug.Print Err.Number, Err.Description
Exit Sub
End If
End Sub
- Reopen the query in Design view. Note that the Description property is blank. Also note that the Description property in the Immediate window is not what you typed. It is the description from the Customers table.
Additional query words:
pra description format input mask caption display control
Keywords : kberrmsg kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug