Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing DB Properties by code in Access 2002

Status
Not open for further replies.

Shake412

Programmer
Apr 17, 2002
55
0
0
GB
in Access 97 I used to be able to programmatically view and change any DB property, such as “AppTitle” or “AppIcon” using the properties collection of the database object. I don’t appear to be able to do this with the ADO equivalent connection object.

What is the Access 2002/ADO equivalent to the following:-

Set db = CurrentProject.Connection
db.Properties(strPropName) = varPropValue

Thanks
 
It's very simple - but it took a lot of working out
In the line where you had
Code:
Dim db As Database

you replace it with
Code:
Dim db As Object

Then recompile and Run !


Here is the full code that I have just snatched from an active Access 2000 db in use here

Code:
Sub SetStartupProperties()
    ChangeProperty "StartupForm", dbtext, "frmStartUp"
    ChangeProperty "StartupShowDBWindow", dbboolean, True   
    ChangeProperty "StartupShowStatusBar", dbboolean, True
    ChangeProperty "AllowBuiltinToolbars", dbboolean, True 
    ChangeProperty "AllowFullMenus", dbboolean, True   
    ChangeProperty "AllowBreakIntoCode", dbboolean, True   
    ChangeProperty "AllowSpecialKeys", dbboolean, True
    ChangeProperty "AllowBypassKey", dbboolean, True      
    MsgBox "DB Properties Have Been Created..."

End Sub

' enable 'SHIFT' key on startup for developer's
Function SetBypassForDeveloper()
    ChangeProperty "AllowBypassKey", dbboolean, True
End Function

' disable 'SHIFT' key on startup for other user's
Function SetBypassForOthers()
    ChangeProperty "AllowBypassKey", dbboolean, False
End Function

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

Change_Bye:
    Exit Function

Change_Err:
    If Err = conPropNotFoundError Then ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function



'ope-that-'elps




G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Actually, Access versions 2000 and up do not reference the DAO library by default, which is what is causing your problem.

Just reference the DAO library (Tools-->References-->Check Microsoft DAO 3.6 Object Library) and your Access 97 code will run fine. This functionality has not changed.

VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top