Setting Application Title

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JustJim
    Recognized Expert Contributor
    • May 2007
    • 407

    Setting Application Title

    Hi all,

    Having done this
    [CODE=vb]Public Const JMCTITLESTRING As String = "New Arrivals 2008"[/CODE]
    and this
    [CODE=vb] Set prpTitle = NAdb.CreateProp erty("AppTitle" , 12, JMCTITLESTRING)
    NAdb.Properties .Append prpTitle
    Application.Ref reshTitleBar[/CODE]
    I can do this, in the immediate window
    Code:
    ? currentdb().Properties("AppTitle").value
    New Arrivals 2008
    Which made me a happy person until I looked at the title bar of the application and it says "Microsoft Access"

    Why is it so?

    Jim
  • Zwoker
    New Member
    • Jul 2007
    • 66

    #2
    I find that the following example code works fine to change the MS Access title bar. It is a little different that what you show in your code...

    Code:
    Dim dbs As Database
    Set dbs = CurrentDb
    dbs.Properties!AppTitle = "Hello World"
    Application.RefreshTitleBar

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      In my system AppTitle doesn't even exist :S

      I did find "Application.Na me" but it's a read-only property (which doesn't surprise me really). Why would you expect this to be a changeable property? Have you seen somewhere that it can be done?

      Comment

      • Scott Price
        Recognized Expert Top Contributor
        • Jul 2007
        • 1384

        #4
        This worked for me using Access 2003... I think you just need to do the .Append method for your new property to work, Jim...

        [CODE=vb]
        Dim db As Database
        Set db = CurrentDb()
        Dim newtitle

        Set newtitle = db.CreateProper ty("AppTitle", dbText, "Test")
        db.Properties.A ppend newtitle
        Application.Ref reshTitleBar[/CODE]

        Regards,
        Scott
        Last edited by Scott Price; Feb 23 '08, 02:22 PM. Reason: additional vital information

        Comment

        • Scott Price
          Recognized Expert Top Contributor
          • Jul 2007
          • 1384

          #5
          Actually after looking again, I see that you have used the .Append... Sorry Jim!

          Regards,
          Scott

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            For some reason there are end users that are intimidated by Access while appearing to have no problem with VB6 looking interfaces. Scott’s code changes the app name, but the ever present Access “Key” is still there. One solution that I've used is to create a "background " form that is sized to fill the entire screen, covering the Access window itself. Then you can set the form's name to whatever you want the "applicatio n name" to be. There are functions out there for running forms while making the Access Window invisible. I sopent a great deal of time experimenting with these and wasn't at all happy with the results. They work fairly well if your app only involves a single form, but handling multiple forms is a nightmare as all forms have to be popup. I also ran into problems with them closing but leaving the LDB file open, which required shutting the entire system to get rid of.

            Linq ;0)>

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              I was being a bit dim.
              You created the property AppTitle - hence why I couldn't find it :S

              Anyway, after trying Scott's code (and by extension Jim's) in A2003 I found that it did work for me after all. That is, it changed the title for the application as well as updating the property value.

              Sorry Jim, I don't know why your's doesnt show.

              Comment

              • Scott Price
                Recognized Expert Top Contributor
                • Jul 2007
                • 1384

                #8
                How are you calling the procedure, Jim?

                I piggy-backed it into the On Click event of a button, which of course, only needs to be called once.

                The only substantial difference I can see in the two codes (yours and mine) is that you are using a constant of 12 where I used the vbText... Have you tried the other?

                Regards,
                Scott

                Comment

                • JustJim
                  Recognized Expert Contributor
                  • May 2007
                  • 407

                  #9
                  Originally posted by Scott Price
                  How are you calling the procedure, Jim?

                  I piggy-backed it into the On Click event of a button, which of course, only needs to be called once.

                  The only substantial difference I can see in the two codes (yours and mine) is that you are using a constant of 12 where I used the vbText... Have you tried the other?

                  Regards,
                  Scott
                  I put the code in the OnOpen event of the form I use as the Main Menu so that it gets run at Application startup.

                  I'll try the vbText constant (can't remember what 12 was, possibly vbChar)

                  Thanks all.
                  Jim

                  Comment

                  • Scott Price
                    Recognized Expert Top Contributor
                    • Jul 2007
                    • 1384

                    #10
                    Just a clearup :-) I mistyped the dbText constant as vbText, Jim, Sorry. It should be dbText as I have in the code.

                    12 is the code for dbMemo. In doing a little testing with NeoPa's help we came up with something that seems to work quite well at changing and re-changing the title when needed. I'll post the updated code here;
                    [CODE=vb]
                    Dim db As Database
                    Set db = CurrentDb()

                    Dim newtitle

                    Set newtitle = db.CreateProper ty("Apptitle", dbText, "Test")
                    'db.Properties. Append newtitle
                    db.Properties(" AppTitle").Valu e = "Test"
                    Call Application.Ref reshTitleBar[/CODE]

                    You'll notice that the .Append line is commented out, it raises an error if called more than once! I.e Access won't allow you to append the same property if it already exists. So the first time the code runs, the new title property needs to be appended, the second time, the .Value needs to be re-set to whatever new title you wish.

                    The RefreshTitleBar call applies whatever change you have made.

                    Hope this helps!

                    Regards,
                    Scott

                    Comment

                    • JustJim
                      Recognized Expert Contributor
                      • May 2007
                      • 407

                      #11
                      Originally posted by Scott Price
                      Just a clearup :-) I mistyped the dbText constant as vbText, Jim, Sorry. It should be dbText as I have in the code.

                      12 is the code for dbMemo. In doing a little testing with NeoPa's help we came up with something that seems to work quite well at changing and re-changing the title when needed. I'll post the updated code here;
                      [CODE=vb]
                      Dim db As Database
                      Set db = CurrentDb()

                      Dim newtitle

                      Set newtitle = db.CreateProper ty("Apptitle", dbText, "Test")
                      'db.Properties. Append newtitle
                      db.Properties(" AppTitle").Valu e = "Test"
                      Call Application.Ref reshTitleBar[/CODE]

                      You'll notice that the .Append line is commented out, it raises an error if called more than once! I.e Access won't allow you to append the same property if it already exists. So the first time the code runs, the new title property needs to be appended, the second time, the .Value needs to be re-set to whatever new title you wish.

                      The RefreshTitleBar call applies whatever change you have made.

                      Hope this helps!

                      Regards,
                      Scott
                      Yes, I didn't actually explain the details but I had the append in the main code and trapped the error to make the change if the property had allready been appended.
                      This has been fun and educational. I'm going to have to wait until I get home to play with it.... my USB key just now fell to pieces as I went to put it in the socket!

                      Thank you to all who assisted.

                      Jim

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32656

                        #12
                        Some alternative code, that handles either occasion using "On Error ...". Remember that once this property has been added to an application installation (not db or user dependent), it is not removable (at least we found no way & I searched the Registry). To restore it you'd need to set it back to "Microsoft Access" (as I had to do after my testing).
                        Code:
                        Public Sub ChangeAppTitle(strTitle as String)
                          Dim proTitle As Property
                        
                          On Error Resume Next
                          With CurrentDB
                            Set proTitle = .CreateProperty("AppTitle", dbText, strTitle)
                            Call .Properties.Append(proTitle)
                            .Properties("AppTitle").Value = strTitle
                          End With
                          Call Application.RefreshTitleBar
                        End Sub

                        Comment

                        Working...