Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 October 5th, 2007, 01:53 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default AllowBypassKey for Access Project

I have created an Access Project file connected to SQL Server.

I want to disable the AllowBypassKey property for the project but the CreateProperty() method of the CurrentDb object does not seem to be available.

Also, CurrentProject object does not have a CreateProperty() method.

I have a reference to Microsoft ADO ActiveX 2.8 Library and Microsfot DAO 3.6 Object Library.

Any ideas how I might disable the Shift key on startup?

 
Old October 11th, 2007, 06:51 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I think you have to do that with Shortcut properties.

The Access 2003 VBA Programmer's Reference mentions the ADE start up wizard that will allow you to prevent users holding down the shift key. See: http://wrox.books24x7.com

You would have to turn your project into an ADE, which is a good thing since it prevents a lot of user interaction with your code, etc.

Did that help any?

mmcdonal
 
Old October 11th, 2007, 06:58 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I also found this:

----------------------------------

Function ap_DisableShift()
'This function will disable the shift at startup causing
'the Autoexec macro and Startup properties to always be executed

    On Error GoTo errDisableShift

    Dim db As DAO.Database
    Dim prop As Property
    Const conPropNotFound = 3270

    Set db = CurrentDb()

    'This next line disables the shift key on startup.
    db.Properties("AllowByPassKey") = False

'function successful
Exit Function

errDisableShift:
    'The first part of this error routine creates the "AllowByPassKey
    'property if it does not exist.
    If Err = conPropNotFound Then
    Set prop = db.CreateProperty("AllowByPassKey", _
        dbBoolean, False)
        db.Properties.Append prop
        Resume Next
    Else
        MsgBox "Function 'ap_DisableShift' did not complete successfully."
        Exit Function
    End If

End Function
----------------------------------

----------------------------------

Function ap_EnableShift()
'This function will enable the shift key at startup causing
'the Autoexec macro and Startup properties to be bypassed
'if the user holds down the shift key when opening the database.

    On Error GoTo errEnableShift

    Dim db As Database
    Dim prop As Property
    Const conPropNotFound = 3270

    Set db = CurrentDb()

    'This next line disables the shift key on startup.
    db.Properties("AllowByPassKey") = True

'function successful
Exit Function

errEnableShift:
    'The first part of this error routine creates the "AllowByPassKey
    'property if it does not exist.
    If Err = conPropNotFound Then
    Set prop = db.CreateProperty("AllowByPassKey", _
        dbBoolean, True)
        db.Properties.Append prop
        Resume Next
    Else
        MsgBox "Function 'ap_DisableShift' did not complete successfully."
        Exit Function
    End If

End Function

----------------------------------

To run the disable shift, paste the above two functions in a module, then, open the debug window. Type: ap_DisableShift and press <return>. You will not be able to use the shift key to get around the startup procedures (including the autoexec macro) until the ap_EnableShift is run on the application.

mmcdonal
 
Old October 11th, 2007, 11:42 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the info....

I was able to disable the Shift key on startup using:

CurrentProject.Properties.ADD "AllowBypassKey", False

To enable Shift key:

CurrentProject.Properties.Remove "AllowBypassKey"

Since this is an Access Project file (.ADP) the method described above had no effect because it modifies the CurrentDb object (.MDB).

Thanks again.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Access project luissilva755 Pro VB.NET 2002/2003 0 October 24th, 2008 11:46 AM
Access Data Project moedev Access 1 April 19th, 2006 06:40 AM
Remote access to an Access Project Database bright_mulenga Access 0 February 9th, 2006 10:51 AM
From 1 project to get access to another project hplim18 Pro VB.NET 2002/2003 0 March 30th, 2004 10:33 PM
Access project refresh VBAHole22 Access 6 July 16th, 2003 11:59 AM





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