UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Apptitle Property Not Found, Access 2016    
 
   
CallMeAndy
post Dec 10 2016, 07:05 AM
Post#1



Posts: 62
Joined: 21-June 05



So apparently Dao.Database still has a propererty pre-established "AppTitle" in Access 2016. As suggested at https://msdn.microsoft.com/en-us/library/of...e/ff194769.aspx and I have seen many other examples confirming its use, but intellisense is not seeing it and neither is it simply unexposed as running code hits the 3270 Property not found error.

Compiling uncovers no errors.

Trying to assign a value doesnt work either by using CurrentDb.Properties.AppTitle or using dbs.Properties!AppTitle or dbs.Properties("AppTitle") where the latter two methods were assigned CurrentDb object. I hit the 3270.

Elsewhere the same application is running on Access 2007 without issue, using the dbs.Properties("AppTitle") = "bla bla bla"

Any thoughts welcome,
Thanks.
Go to the top of the page
 
moke123
post Dec 10 2016, 07:42 AM
Post#2



Posts: 1,335
Joined: 26-December 12
From: Western Ma.,L.I.,N.Y.,Jupiter,Fl.



this code appears to work properly to set the AppTitle. In testing it, it doesnt get the 3270 error.

CODE
Public Function SetAppTitle(strPropValue As String) As Boolean

'Usage -   Call SetAppTitle("Your Title Here")


On Error GoTo ErrHandle

    Dim db As DAO.Database
    Dim doc As DAO.Document
    Dim prp As DAO.Property

    Set db = CurrentDb

    Set doc = db.Containers!Databases.Documents!MSysDb
    doc.Properties.Refresh

    Set prp = doc.Properties("AppTitle")
    prp.Value = strPropValue

    SetAppTitle = True

ExitHere:
    On Error Resume Next
    'Show the change on the Title Bar
    Application.RefreshTitleBar
    Set prp = Nothing
    Set doc = Nothing
    Set db = Nothing
    Exit Function

ErrHandle:
    'If property not found, create it.
    If Err = 3270 Then
        Set prp = db.CreateProperty("AppTitle", dbText, strPropValue)
        db.Containers!Databases.Documents!MSysDb.Properties.Append prp
        SetAppTitle = True
    Else
        MsgBox "Error #" & Err.Number & " " & Err.Description _
        & "In Procedure SetAppTitle"
    End If
    Resume ExitHere

End Function
Go to the top of the page
 
GroverParkGeorge
post Dec 10 2016, 08:58 AM
Post#3


UA Admin
Posts: 34,314
Joined: 20-June 02
From: Newcastle, WA


It is true that the Apptitle property isn't set by default, so moke's code would work to append it and then set it to the value you pass in.

Once it's been applied, of course, to a given accdb, then it wouldn't error on subsequent runs of the same Function(), although it could be changed if you wanted to do that for some reason.



.
Go to the top of the page
 
CallMeAndy
post Dec 10 2016, 12:47 PM
Post#4



Posts: 62
Joined: 21-June 05



Thanks for coming back guys.

I have not seen the doc oriented approach, and as per the ms page AppTitle appears be a property already available via the Database object, but either way......

Set prp = doc.Properties("AppTitle")

does indeed get a 3270 and trips to the Error Handler, thus creating the property. And subsequently passes as expected ,so this allows issue closure.

Thanks a bunch chaps.
Go to the top of the page
 
GroverParkGeorge
post Dec 10 2016, 12:59 PM
Post#5


UA Admin
Posts: 34,314
Joined: 20-June 02
From: Newcastle, WA


As I told you, it is NOT set by default, and is not present in the Properties collection until you have created and appended it. At that point you can give it a value. That's what Moke's sample does. I've been using a similar function to APPEND the AppTitle property (and a couple of others) for a long time. That's how it works.

On the other hand, as I also pointed out, once it's appended to the Properties collection, it remains.
Go to the top of the page
 
CallMeAndy
post Dec 10 2016, 01:14 PM
Post#6



Posts: 62
Joined: 21-June 05



Yes indeed you did tell me and my intention was to confirm that it does indeed worrk as you expected. But I laced the confirmation, perhaps confusingly, with a further implied question, which is:
What then is the meaning of the MS page stating that DAO.Database has Microsoft Access–defined properties, including AppTitle? In what circumstances can you access this defined property?
Go to the top of the page
 
GroverParkGeorge
post Dec 10 2016, 01:24 PM
Post#7


UA Admin
Posts: 34,314
Joined: 20-June 02
From: Newcastle, WA


I believe that the MSDN page is misleading. It's possible to access it when you have appended it to the properties collection and assigned it a value.
Go to the top of the page
 
theDBguy
post Dec 10 2016, 01:38 PM
Post#8


Access Wiki and Forums Moderator
Posts: 74,178
Joined: 19-June 07
From: SunnySandyEggo


Hi Andy,

I don't presume to know what the MSDN authors were thinking when they wrote the article, but I am willing to take a stab at explaining what they might mean when they say "The following table lists some Access–defined properties that apply to DAO objects."

In a sense, I take it as something similar to VBA having a set of defined functions. You can of course create your own custom functions but creating one with the same name as one already defined might cause some problems.

So, Access has a pre-defined property called "AppTitle." If this property exists, Access then uses it to display the assigned title for the database application. Otherwise, it will display a default value. I think the confusion comes from having to remember not all defined properties are automatically available in the database. You may have to create and append it first before you can use it.

If you create a custom property, then Access will not know how to use it because it is not "pre-defined."

Hope it makes sense...
Go to the top of the page
 
CallMeAndy
post Dec 13 2016, 01:31 PM
Post#9



Posts: 62
Joined: 21-June 05



OK so I accept this is how it works. Thanks again for pointing my right on this guys. But this seems a bizarre and logicless mechanism. What am I not seeing here?
If there was logic in effectivly, having to activate pre-declared properties, then why is this not done anywhere else, at least across programming languages that I have been exposed to. In VBA terms its rather like having a Command Button class where you had to append Caption to the activated propererties list before you could attribute a label! What is it that is different about the nature of these properties compared to controls for instance?
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    17th January 2019 - 10:19 PM