[AccessD] Detecting External References From With-In an MDE?

John W. Colby jwcolby at colbyconsulting.com
Sun Jul 25 13:53:35 CDT 2004


Robert,

I doubt it seriously.  That would require code to run inside the db
triggered by a reference being set to the db.  An mde is just a library of
code and is not supposed to run code "on its own".

JWC

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Robert Gracie
Sent: Sunday, July 25, 2004 1:12 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Detecting External References From With-In an MDE?



 Yea, that lists the reference made from within the database, but what I
need is to "Detect" references (external connections) to the mde.

 Does this make any sense?


Robert Gracie
www.servicexp.com


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Gustav Brock
Sent: Sunday, July 25, 2004 10:07 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Detecting External References From With-In an MDE?


Hi Robert

>  How can I list them?, I know how to get the reference collection for 
> the "internal" references, but I have no idea how to find any external 
> (other databases or programs connected (Referenced) to the mde) 
> references.

Here is one method, filling a table:

<code>

Option Compare Database
Option Explicit

' Declarations and functions for creating and storing
' a list (table) of the current References.
'
' 2001-08-20. Cactus Data ApS, CPH.

  ' Length of GUID string per definition.
  Private Const clngGUID                As Long = 38

  Type GuidDefinition
    Guid As String * clngGUID
    Major As Integer
    Minor As Integer
  End Type

  ' Minimum Guid version.
  Private Const cintMajorMinVersion     As Integer = 1
  Private Const cintMinorMinVersion     As Integer = 0

  Private Const cstrReferencesTableName As String = "USysReferences"
  Private Const cintLocalTable          As Integer = 1


Public Function CreateTableReferences() As Boolean

  Dim strSQL As String

  On Error Resume Next

  ' Create, without using DAO, table cstrReferencesTableName.
  strSQL = vbNullString & _
    "CREATE TABLE " & cstrReferencesTableName & " " & _
      "(" & _
        "GuidString TEXT(38), " & _
        "Major SMALLINT, " & _
        "Minor SMALLINT, " & _
        "Name TEXT(255) NOT NULL, " & _
        "FullPath TEXT(255), " & _
        "MajorMin SMALLINT, " & _
        "MinorMin SMALLINT, " & _
        "CONSTRAINT idxGuid PRIMARY KEY (GuidString)" & _
      ")" & _
    ";"

  DBEngine(0)(0).Execute (strSQL)

  CreateTableReferences = (Err = 0)

End Function


Public Function PopulateTableReferences( _
  Optional ByVal booDisableLowerGuidVersions As Boolean) _
  As Boolean

  Dim ref     As Reference
  Dim strSQL  As String

  ' If booDisableLowerGuidVersions is True, minimum values for Guid version
  ' will be set equal to current Guid version.
  ' If booDisableLowerGuidVersions is False, minimum values for Guid version
  ' will be set as defined by the global variables:
  ' cintMajorMinVersion
  ' cintMinorMinVersion

  On Error Resume Next

  ' Empty, without using DAO, table cstrReferencesTableName.
  strSQL = "DELETE * FROM " & cstrReferencesTableName & ";"
  DBEngine(0)(0).Execute (strSQL)

  ' Populate, without using DAO, table cstrReferencesTableName.
  For Each ref In References
    With ref
      strSQL = vbNullString & _
        "INSERT INTO " & cstrReferencesTableName & " " & _
          "VALUES(" & _
            "'" & .Guid & "', " & _
            "" & .Major & ", " & _
            "" & .Minor & ", " & _
            "'" & .Name & "', " & _
            "'" & .FullPath & "', " & _
            "" & IIf(booDisableLowerGuidVersions, .Major,
cintMajorMinVersion) & ", " & _
            "" & IIf(booDisableLowerGuidVersions, .Minor,
cintMinorMinVersion) & "" & _
          ")" & _
        ";"
      DBEngine(0)(0).Execute (strSQL)
    End With
  Next

  Set ref = Nothing

  PopulateTableReferences = (Err = 0)

End Function

</code>

You can easily reduce it to just run a Debug.Print list if you wish.

/gustav


> You can list them but, as far as I know, not change them - that's one 
> of the limitations of an mde.

> /gustav


>> A2k
>>  Is it possible to detect external references made on an .mde from 
>> within the mde?

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


-- 
_______________________________________________
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