[AccessD] Broken References in Runtime AXP

Charlotte Foust cfoust at infostatsystems.com
Thu Jul 17 17:26:34 CDT 2003


Um, with a broken reference, you have to substitute the numeric value of
constants in your code, and even then you can get odd results.  For
example SysCmd(acSysCmdRuntime) or its numeric equivalent don't seem to
recognize a runtime session.  Anyhow, I substituted equivalents and
still didn't get a reliable result.  For one thing, the VBA.Dir command
didn't seem to always like the FullPath.  When I stepped through the
code in a normal session, Dir returned a value greater than zero for the
FullPath even though the file isn't there and the IsBroken property at
that point reported True, which is correct.  Heaven knows what happens
in runtime though because it wasn't working.  

The only thing I've found that does seem to work is to use Dir to test
the parsed out path and filename to see if it exists, so maybe there's a
null character at the end of FullPath.  And even that seems to return
spotty results.  I works when I step through it but doesn't always work
at runtime.  What really looks weird is that the reference object seems
to sometimes return a correct path for the broken reference, even though
the reference itself points elsewhere! 

Sorry, I have to go now.  They're coming to take me away ....

Charlotte Foust



-----Original Message-----
From: Gustav Brock [mailto:gustav at cactus.dk] 
Sent: Thursday, July 17, 2003 10:22 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Broken References in Runtime AXP


Hi Charlotte

Interesting and scaring.
Does this mean that the old A97 bug is still alive two versions later??

Would you mind testing the function below to verify if this is still so?


<code>

Public Function IsBroken97(ByVal ref As Access.Reference) As Boolean

' Alternative method to check if a reference is broken
' as the IsBroken property cannot be used in Access97.
'
' 2000-03-19. Gustav Brock. Cactus Data ApS.

' Refer to this article at Microsoft Technet:
'
' Article ID: Q186720
'
' The information in this article applies to:
' Microsoft Access 97
'
' SYMPTOMS
' In Microsoft Access, IsBroken is a property of the References
collection. ' The Microsoft Access Help topic on the Isbroken property
states the following: ' ' The IsBroken property returns a Boolean value
indicating whether a ' Reference object points to a valid reference in
the Windows Registry. ' ' Although this statement is correct, to receive
this Boolean value ' you must trap for errors that are generated by the
broken reference. ' Also, the IsBroken property becomes True only when
the file being referenced ' is deleted and the Microsoft Windows Recycle
Bin is emptied. ' This article details the steps necessary to receive
the Boolean value.

  Dim booRefOK As Boolean
  On Error GoTo Err_IsBroken97
  
  If Len(Dir(ref.FullPath, vbNormal)) > 0 Then
    booRefOK = Not ref.IsBroken
  End If

Exit_IsBroken97:
  IsBroken97 = Not booRefOK
  Exit Function

Err_IsBroken97:
  ' Ignore non existing servers, drives, and paths.
  Resume Exit_IsBroken97
  
End Function

</code>

/gustav


> Yes, but I've tracked down the problem ... Or at least one of them.  I

> had taken it on faith that the BrokenReference method would actually 
> return a -1 when a reference to another database was missing and that 
> the IsBroken property of the reference object would return a -1 in 
> that case as well.  Apparently, even fully disambiguated, that isn't 
> true. Now I need to figure out how to NOT run it every time the 
> application starts!  I had to resort to writing directly to a text 
> file to figure out where it was going haywire.

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list