Accessing Hyperlink Base property from Visual Basic (1 Viewer)

J

james_ec

Guest
I wonder if anyone can help. What I need to do is assign the Hyperlink Base property of my database to a string using Visual Basic, but I have know idea how to access it in Visual Basic. I'm sure it is easy if you know how, but I am wasting hours!
Help much appreciated.
james
 

charityg

Registered User.
Local time
Today, 23:56
Joined
Apr 17, 2001
Messages
634
Add this function to your db
Code:
Function GetSummaryInfo(strPropName As String, Optional varFileName As Variant) As String
  ' Comments: Get "Summary" properties of Database.  Taken
  '           from Access97 help file.
  ' Parameters: strPropName = Name of property
  ' Return: "None" is returned if the property hasn't already been set.
  '         If an unknown error occurs, a zero-length string (" ") is returned.
  ' Dependencies: None
  ' Created: 9/15/00 MAW
  ' Modified:6/19/01 SDK to accept varFileName as additional arg. to work with external db's.
  '
  ' -------------------------------------------------------
  Dim dbs As DAO.Database, cnt As DAO.Container
  Dim doc As DAO.Document, prp As DAO.Property

  ' Property not found error.
  Const conPropertyNotFound = 3270
  On Error GoTo GetSummary_Err
  
  If IsMissing(varFileName) Then
    Set dbs = CurrentDb
  Else
    On Error Resume Next
    Set dbs = DBEngine.OpenDatabase(varFileName)
    If Err <> 0 Then
        GetSummaryInfo = ""
        GoTo GetSummary_Bye
    End If
  End If
  
  Set cnt = dbs.Containers!Databases
  Set doc = cnt.Documents!SummaryInfo
  doc.Properties.Refresh
  
  For Each prop In doc.Properties
    Debug.Print prop.Name & ": " & prop.Value
  Next
  
  GetSummaryInfo = doc.Properties(strPropName)

GetSummary_Bye:
  Set dbs = Nothing
  Set cnt = Nothing
  Set doc = Nothing
  Exit Function

GetSummary_Err:
  If Err = conPropertyNotFound Then
    Set prp = doc.CreateProperty(strPropName, dbText, "None")
    ' Append to collection.
    doc.Properties.Append prp
    Resume
  Else

' Unknown error.
    GetSummaryInfo = ""
    Resume GetSummary_Bye
  End If
End Function

Then
Code:
yourstringname=GetSummaryInfo("hyperlink base")

Hope this helps!
 
J

james_ec

Guest
Thanks!

You have just made me one happy man!

Thanks a lot, had to reset the references in Visual Basic to refer to the DAO 3.6 Object Library, then worked perfectly.

Thanks

james
 

Users who are viewing this thread

Top Bottom