Change Applicatin Title in Access 2003

gavinjb

Registered User.
Local time
Today, 14:55
Joined
Mar 23, 2006
Messages
39
Hi,

I am trying to use some Access 2000 code to change the access application title, but whenever I run the code I get an "Error 91 Object variable or With block variable not set" error message on the DB.Properties(prpName) = prpValue statement, does anyone have any ideas what I am doing wrong, I have checked the DAO is referenced in this database.

Code:
Function SetApplicationTitle(ByVal MyTitle As String)
   If SetStartupProperty("AppTitle", dbText, MyTitle) Then
      Application.RefreshTitleBar
   Else
      MsgBox "ERROR: Could not set Application Title"
   End If
End Function

Function SetStartupProperty(prpName As String, _
      prpType As Variant, prpValue As Variant) As Integer
   Dim DB As DAO.DATABASE
   Dim PRP As DAO.Property
   Dim WS As DAO.Workspace
   
   Const ERROR_PROPNOTFOUND = 3270


   Set DB = CurrentDb()
   
   ' Set the startup property value.
   On Error GoTo Err_SetStartupProperty
   DB.Properties(prpName) = prpValue
   SetStartupProperty = True

Bye_SetStartupProperty:
   Exit Function

Err_SetStartupProperty:
   Select Case Err
   ' If the property does not exist, create it and try again.
   Case ERROR_PROPNOTFOUND
      Set PRP = DB.CreateProperty(prpName, prpType, prpValue)
      DB.Properties.Append PRP
      Resume
   Case Else
      Debug.Print Err.Number & vbCrLf & Err.Description
      SetStartupProperty = False
      Resume Bye_SetStartupProperty
   End Select
End Function


Thanks,



Gavin,
 
I know this is a bit late, but for the sake of giving the info to anybody looking, I found the following code in the Access Help for changing the title:


Code:
Sub ChangeTitle()
    Dim dbs As Database
    Dim obj As Object
    Const conPropNotFoundError = 3270
    
    On Error GoTo ErrorHandler
    ' Return Database object variable pointing to
    ' the current database.
    Set dbs = CurrentDb
    ' Change title bar.
    dbs.Properties!AppTitle = "New Name for Database"
    ' Update title bar on screen.
    Application.RefreshTitleBar
    Exit Sub
    
ErrorHandler:
    If Err.Number = conPropNotFoundError Then
        Set obj = dbs.CreateProperty("AppTitle", dbText, "New Name for  Database")
        dbs.Properties.Append obj
    Else
        MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
    End If
    Resume Next
End Sub
 

Users who are viewing this thread

Back
Top Bottom