Wrox Programmer Forums
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 29th, 2003, 05:22 PM
Authorized User
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default Allow ByPassKey property

Hello Folks

I have no idea what i'm doing wrong but i'm trying to disable the shift key bypass and its not working right. I researched it in the VBA help and came across the following code.

Sub SetBypassProperty()
Const DB_Boolean As Long = 1
    ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub

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

    Exit Function

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

Could somebody tell me what i'm doing wrong. This is Office 2003 on XP

Thanks in advance.


Old December 30th, 2003, 03:39 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts

Looks like you've posted the example from the help file.
I've noticed that sometimes it doesn't work for me either. Basically, sometimes the error trapping part for if the property doesn't exist, doesn't work
So what you could do, to get around this, is just run this code first, to add the property (which is basically rephrasing the error trapping part of your code)
Function DoStuff()
Dim prp
Set prp = CurrentDb.CreateProperty("AllowByPassKey", 1, False)
CurrentDb.Properties.Append prp
End Function

I am a loud man with a very large hat. This means I am in charge
Old January 3rd, 2004, 08:39 PM
Authorized User
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman

Not to be an idiot, but i tried to paste that code into the project as well and it didn't work either. How do i execute the code to get it to add the property. I have done this in office xp but it doesn't seem to work in office 2003. Thanks for your help

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable Property kekec3778 Beginning VB 6 2 January 8th, 2008 06:32 AM
property umeshtheone Beginning VB 6 2 May 18th, 2007 12:37 AM
the ConnectionString Property... coolb C# 3 September 26th, 2006 02:05 AM
How To Get Browser Property shek_lko PHP How-To 2 May 21st, 2006 10:59 PM
The ConnectionString property...! rajesh0363 All Other Wrox Books 2 July 26th, 2005 01:55 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.