NOTE: This issue often involves references to Comctl32.ocx. But this issue can also occur with other type libraries. An example of installing a newer type library version is installing newer versions of Microsoft Data Access Components (MDAC). Sometimes the upgrade of a type library is subtle, such as when you upgrade the operating system version or install a new application.
IMPORTANT NOTE ON MDE FILES: The following methods work only in standard Access files (.mdb). You cannot refresh references in an Access MDE (.mde) file. References must be refreshed in the original .mdb file before being recompiled into a new .mde.
Using Microsoft Access to Refresh a ReferenceYou can use Microsoft Access to refresh the references on a target computer manually. To do so, follow these steps:
- Open the database that causes the errors mentioned in the "Symptoms" section.
- On the Modules tab, click New.
- On the Tools menu, click References.
- In the References dialog box, pick any single reference that is not already selected, click to select it, note which one you selected, and then click OK.
- On the Tools menu, click References again.
- Click to clear the reference that you selected in step 4, and then click OK.
- Run the query, the form, or the report on which you saw the errors mentioned in the "Symptoms" section. No errors occur.
Updating the Distributed ControlYou can update the version of the control on your development computer to match the one on your target computer. After you have updated the control on your development computer and refreshed the reference to it in your database (see the "Using Microsoft Access 97 to Refresh a Reference" section earlier in this article), you can copy the database back onto the target computers.
If you are using the Microsoft Office 97 Developer Edition (ODE) to distribute an application, run the Setup Wizard again to rebuild the setup files, and then have users reinstall the application.
Automatically Refreshing References by Using Visual Basic for ApplicationsYou can use Visual Basic for Applications code to refresh the references in your database automatically. This solution uses a query to test for the problem described by this article, and then runs Visual Basic for Applications code to refresh the references if the problem exists. If you are distributing ODE applications, you can include this in both future and upgrade versions of your application.
- Create a new query in your database to test for the symptoms. The query needs to use one of the built-in Access functions, for example the Format(), Left(), or Right() function. Save the query as qryTestRefs.
For example, using the Northwind database, you could use a query that returns the first letter of the Category Name field in the Category table, as follows:
Value: Left([Category Name],1)
- Create a macro as follows, and save it as AutoExec:
Macro Name Action
Function Name: CheckRefs()
- Create the following module, and type or paste the following code into the new module:
Dim db As Database, rs As Recordset
Set db = CurrentDb
On Error Resume Next
' Run the query qryTestRefs you created and trap for an error.
Set rs = db.OpenRecordset("qryTestRefs", dbOpenDynaset)
' The if statement below checks for error 3075. If it encounters the
' error, it informs the user that it needs to fix the application.
' Error 3075 is the following:
' "Function isn't available in expressions in query expression..."
' Note: This function only checks for the error 3075. If you want it to
' check for other errors, you can modify the If statement. To have
' it check for any error, you can change it to the following:
' If Err.Number <> 0
If Err.Number = 3075 Then
MsgBox "This application has detected newer versions " _
& "of required files on your computer. " _
& "It may take several minutes to recompile " _
& "this application."
Dim loRef As Access.Reference
Dim intCount As Integer
Dim intX As Integer
Dim blnBroke As Boolean
Dim strPath As String
On Error Resume Next
'Count the number of references in the database
intCount = Access.References.Count
'Loop through each reference in the database
'and determine if the reference is broken.
'If it is broken, remove the Reference and add it back.
For intX = intCount To 1 Step -1
Set loRef = Access.References(intX)
blnBroke = .IsBroken
If blnBroke = True Or Err <> 0 Then
strPath = .FullPath
Set loRef = Nothing
' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
Steps to Reproduce Problem
- Reformat two test computers.
- Install Microsoft Windows 95 or Microsoft Windows 98 on both computers.
- On the first computer, install Microsoft Access 97.
- On the first computer, install Microsoft Office 97 Developer Edition.
- On the first computer, create a new database.
- In the new database, click Tables, click New, and then click Design View.
- In Design view, create the following new table:
Field Name: CategoryID
Data Type: Counter
Indexed: Yes (No Duplicates)
Field Name: CategoryName
Data Type: Text
Field Name: Location
Date Type: Text
Field Size: 20
Indexed: Yes (Duplicates OK)
Table Properties: Table1
Index1: CategoryName; Location
- Save the table as Table1, and then switch to Datasheet view.
- In Datasheet view, add a few records to the table.
- Create a new query based on the table.
- Add the Field1 field to the query, as well as the following expression:
EXPR1: Format([CategoryID], " #")
- Save the query as Query1, and then close it. Do not run the query.
- Open a new, blank form in Design view.
- Insert the Microsoft CommonDialog (version 5.0) and the Microsoft Treeview (version 5.0) controls on the form.
- On the View menu, click Code to see the module of the form. (This automatically sets the HasModule property to Yes.)
- On the Tools menu, click References, and verify that you have the following references (in order):
Visual Basic For Applications
Microsoft Access 8.0 Object Library
Microsoft DAO 3.5 Object Library
Microsoft Common Dialog Control 5.0
Microsoft Windows Common Controls 5.0
- On the Debug menu, click Compile And Save All Modules. Save the form as Form1 when you are prompted.
- Close the form.
- Run the Query1 query and verify that it works correctly.
- Copy the database to a second computer that has version 5.00.4319 or later of COMCTL32.OCX installed. This version of the control can be obtained with Microsoft Visual Studio 5.0 SP3 or Visual Studio 6.0.
- Open the database on the second computer and run the Query1 query. Note that you receive the following error message:Function isn't available in expressions in query expression 'Format([CategoryID], " #")'
ID articolo: 194374 - Ultima revisione: 23 gen 2007 - Revisione: 1