Results 1 to 7 of 7
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Set Application Title in Startup in Code (Access 2000/Win95)

    Does anybody know how to set the Application Title field in the startup box in VBA code?
    Appreciate any help !!
    Pat <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Set Application Title in Startup in Code (Access 2000/Win95)

    Here is example of one way to do this, using a standard "AddAppProperty" function:

    Public Sub SetAppTitle(strAppTitle As String)

    Dim n As Integer
    n = AddAppProperty("AppTitle", dbText, strAppTitle)
    Application.RefreshTitleBar

    End Sub

    Public Function AddAppProperty(strName As String, varType As Variant, _
    varValue As Variant)
    On Error GoTo Err_Handler
    Dim strMsg As String

    Dim db As DAO.Database
    Dim prop As DAO.Property

    Set db = CurrentDb
    db.Properties(strName) = varValue

    Exit_Sub:
    Set db = Nothing
    Set prop = Nothing
    Exit Function
    Err_Handler:
    If Err = 3270 Then 'Property not found
    Set prop = db.CreateProperty(strName, varType, varValue)
    db.Properties.Append prop
    Resume
    Else
    strMsg = "Error No " & Err.Number & ": " & Err.Description
    Beep
    MsgBox strMsg, vbExclamation, "ERROR MESSAGE"
    Resume Exit_Sub
    End If

    End Function

    HTH

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Set Application Title in Startup in Code (Access 2000/Win95)

    That's sounds great Mark, but what I omitted to ask was, can you apply it to a database that is not the current database?
    Is is just a matter of replacing the
    Set db = CurrentDb
    with
    Set db = OpenDatabase(xxx)
    Pat <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Set Application Title in Startup in Code (Access 2000/Win95)

    Here is modified example for setting app title for a database other than current one:

    Public Sub SetAppTitleEx(strDB As String, strAppTitle As String)

    AddAppPropertyEx strDB, "AppTitle", dbText, strAppTitle

    End Sub

    Public Sub AddAppPropertyEx(strDB As String, strName As String, _
    varType As Variant, varValue As Variant)
    On Error GoTo Err_Handler

    Dim ws As DAO.Workspace
    Dim db As DAO.Database
    Dim prop As DAO.Property
    Dim strMsg As String

    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase(strDB)
    db.Properties(strName) = varValue

    Exit_Sub:
    db.Close
    Set ws = Nothing
    Set db = Nothing
    Set prop = Nothing
    Exit Sub
    Err_Handler:
    If Err = 3270 Then
    Set prop = db.CreateProperty(strName, varType, varValue)
    db.Properties.Append prop
    Resume
    Else
    strMsg = "Error No " & Err.Number & ": " & Err.Description
    Beep
    MsgBox strMsg, vbExclamation, "ERROR MESSAGE"
    Resume Exit_Sub
    End If

    End Sub

    In this example, for strDB argument provide complete path/filename for external database. Example:

    SetAppTitleEx "C:ACCESSCopy of Northwind.mdb","BOGUS APP TITLE"

    HTH

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Set Application Title in Startup in Code (Access 2000/Win95)

    Thank you, that has worked well.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Set Application Title in Startup in Code (Access 2000/Win95)

    Forgive a dumb question, but why would you do this for a database that wasn't the current database? If it isn't the current database, you can't see it anyhow. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    Charlotte

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Set Application Title in Startup in Code (Access 2000/Win95)

    It's not a dumb question Charlotte, yours never are <img src=/S/grovel.gif border=0 alt=grovel width=31 height=23>.
    What I have done in this application is to copy a database named RacingGameBE.mdb to another and named it 'RacingGameyyyy.mdb' where yyyy is the year.
    I then decided that it would be nice to give the new database it's correct name, so that if I ever have to open any more than one of these created databases, it would be obvious by the task bar at the bottom of the screen.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •