Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remove MS Access Missing References though VBA

Posted on 2004-10-07
9
Medium Priority
?
215 Views
Last Modified: 2012-05-05
Is there a way to remove broken references in an Access application through VBA?
For example,
An MDB has a reference to Outlook 2003 lib (msoutl.olb).
When run in an MSOffice 2000 environment this reference is broken ("MISSNG:...")  because the path to msoutl.olb is different in Office9 (2000).
Is there a way to either:
1. Update the FullPath of the missing reference (.FullPath is read-only)
2. Remove the missing reference and insert a new one (.Remove method of References collection fails with Run-time error -2147319779 (Object library not registered) )

Please note that I want to do this from VBA or a VB.exe using the Access.Application object, NOT through user interaction via the references window.

PS. To reproduce the behaviour, place a reference to Microsoft Office 11.0 Object Library in an mdb, rename msoutl.olb found in C:\Program Files\Microsoft Office\OFFICE11\MSOUTL.OLB (Replace OFFICE11 with your Office version) and run the MDB. The reference should appear as missing and the code (any code using for example Left$,Right$) will break..

Thanks in advance for your time
0
Comment
Question by:yiapap
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12247615
Why don't you just use late binding?
0
 

Author Comment

by:yiapap
ID: 12247637
Late binding as in CreateObject?
0
 

Author Comment

by:yiapap
ID: 12247677
Correction in my PS.
To reproduce the behaviour you need to move the MDB to an Office 2000 environment. The example I'm giving requires different handling.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Expert Comment

by:EDDYKT
ID: 12248073
Using a late binding in your code

ie

dim a

set a = createobject("Access.application")

In this case, even the program will run slower but it is independent on what version the user loaded on their machine
0
 

Author Comment

by:yiapap
ID: 12252425
The problem with that is that I will not have access to the properties and methods of the created objects in the VB editor. I will only be able to use the object browser to remember them and their parameters.

I'm also not very sure as to how some pieces of code will "react". In the Outlook example, there's code that manipulates dozens of emails amongst potentially thousands in the user's Inbox. The code is already very time consuming although I have made any and all imaginable optimisations!

In any case, I'll try your suggestion, by programming using early binding and changing to late binding before deploying.
Thanks for the help.
I will leave this Q open for a few more days, just in case someone comes up with the answer to the actual question.

Thanks again,
Yiannis
0
 

Author Comment

by:yiapap
ID: 12278769
There are some problem with late binding.
Some of the classes like Outlook.NameSpace and Outlook.ContactItem cannot be created through the CreateObject method.

In the following function where the functions resulting type is now Variant for example:
Public Function GetContact(ByVal sID As String) ' As Outlook.ContactItem
....
Set ns = ol.GetNamespace("MAPI")
Set fdContacts = ns.GetDefaultFolder(olFolderContacts)
Set ContactItems = fdContacts.Items.Restrict(scriteria)
For Each lContact In ContactItems
    If Trim(UCase(lContact.User1)) = sID Then
        Set GetContact = lContact
        GoTo Exit_Point:
    End If
...

The line Set GetContact=lContact does NOT return an ContactItem.
Although the description of GetContact is Variant/Object/ContactItem I cannot use any of the class properties/methods.

In contrast the line:
Set GetContact = fdContacts.Items.Add
works like a charm!


Thanks again.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12663857
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question