References In Access

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I need to delete a reference programatically if it is
missing (e.g. the IsBroken is set to true). I have tried
the standard offering the KB offers about
References.Remove ref, but I always get the message that
this object isn't registered, so it can never get
removed. Anyone have any ideas?
Thanks in advance
 
Thanks, but it doesn't help. As long as a reference is
listed as missing, you can never execute any diambiguated
code. There should be a way to remove a missing
reference. Trigeminal only discusses registering a
library that is missing, but I don't want to do that, I
want to use the version of the library that the
workstation has!
 
You cannot work with broken references.

If you are talking working with what ever version of Word or Excel is
installed for example, you may be able to use late binding. Just declare the
variable As Object instead of as a specific kind of object. The code will
compile without binding to any particular library. Then at runtime, the
object will be resolved based on the version of the library installed on the
user's computer.
 
"...you can never execute any diambiguated code..."

That is the point of Michael's article.

You did get to http://www.trigeminal.com/usenet/usenet026.asp?1033, didn't
you?

He clearly says in step #2; "Make every function call to the VBA or Access
libraries explicit so that VBA never needs to disambiguate."

If you follow all of his instructions, you should be able to run the code in
the article at
http://support.microsoft.com/default.aspx?scid=kb;EN-US;209849 to see if you
have any broken references. There is also information in the VBA help file
under the "IsBroken Property" topic.

From there you can fix/delete/add references.

Look at the information for the References Collection, the Remove Method,
the AddFromFile Method, the AddFromGuid Method, and a topic called "Set
References to Type Libraries."

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #17 of 19: 1 billion billion picolos = 1 gigolo
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
I haven't had any problems removing references
that are actually missing. What kind of errors
are you getting?

(david)
 
Steve said:
Thanks, but it doesn't help. As long as a reference is
listed as missing, you can never execute any diambiguated
code. There should be a way to remove a missing
reference. Trigeminal only discusses registering a
library that is missing, but I don't want to do that, I
want to use the version of the library that the
workstation has!
 
What we do is turn off all but essential references when
clossing down the database (so each time it starts up it
is forced to find the libraries). We leave on VBA,
Access, Office and MS-ADO 2.1

When it is starting up (ie the first function the
database runs) does the following (just included one
reference here). Of course there are easier ways of
doing this but I need to be able to deal with
English/French (Windows and/or Office) and versions from
Windows 98 to Windows XP. So far it is fairly bullet
proof. Someone else might make it more elegant though :-)



On Error GoTo ErrorReferences
boolAdd = False

'check for reference
Set ref = Application.References("adodb")
'if missing change the flag ( in xxx_Err)
If boolAdd Then
'need to deal with if the computer is english or french
'then set the reference
If fs.folderexists(strDriveLetter & cstrRoot &
cstrComFilFr) Then
Set ref = Application.References.AddFromFile
(strDriveLetter & cstrRoot & cstrComFilFr & cstrSysADO &
cstrADO)
Else
Set ref = Application.References.AddFromFile
(strDriveLetter & cstrRoot & cstrComFil & cstrSysADO &
cstrADO)
End If
boolAdd = False
End If

ErrorReferences:
Select Case Err.Number
Case 9
boolAdd = True
Resume Next
Case Else
MsgBox Err.Description & " " & Err.Number
Resume ExitReferences
End Select
 
The problem occurs when I take a database from a windows
XP machine to a Windows 2000 machine. I have different
versions of ADODB, Office, and so on. When I start up the
database, the references to the newer version are listed
as missing. When I use the References.remove method, I am
told the type library is not registered, and it fails to
remove it from the references list. Therefore, I cannot
execute the code (I refuse to disambiguate everything!)
 
I completely agree with those statements. What I have a
problem with is the fact that the References.Remove method
will NOT remove a missing reference, because the type
library is not registered. My question is how to get
around this issue with disambiguating all code.
-----Original Message-----
"...you can never execute any diambiguated code..."

That is the point of Michael's article.

You did get to
http://www.trigeminal.com/usenet/usenet026.asp?1033, didn't
 
I don't disambiguate 'everything' by I certainly disambiguate
my reference removal function.

And I didn't do it just to make the code more robust: I
needed to check and wanted to see which type libraries
I was referencing in this section of code.

BTW, The 'reference' type is defined in the Access Type
Library. If the reference to the Access Type library is
broken, you won't be able to use the 'remove' method.

(david)
 
Back
Top