Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 3rd, 2003, 07:12 AM
Authorized User
 
Join Date: Dec 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Enable Shift Key to By Pass Macro!

I have added the following code to my project to stop users holding down the shift key to by pass the macro:

Sub SetStartupProperties()

    ChangeProperty "AllowBypassKey", dbBoolean, False

End Sub



Function ChangeProperty()

    Dim strPropName As String

    Dim varPropType As Variant

    Dim varPropValue As Variant



    Dim dbs As Database, prp As Property

    Const conPropNotFoundError = 3270

    strPropName = "AllowBypassKey"

    varPropType = dbBoolean

    varPropValue = False

    Set dbs = CurrentDb

    On Error GoTo Change_Err

    dbs.Properties(strPropName) = varPropValue

    ChangeProperty = True

MsgBox "Welcome to First Choice"

Change_Bye:

    Exit Function



Change_Err:

    If Err = conPropNotFoundError Then ' Property not found.

        Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)

        dbs.Properties.Append prp

        MsgBox "Please Try Again"

        Resume Next

    Else

        ' Unknown error.

        MsgBox "ok"

        ChangeProperty = False

        Resume Change_Bye

    End If

End Function



Now i have done that and it works fine. Now i want to change it back so the Shift key is enabled so i can go back into the database and edit it. I have tries changing the True/False values around but that does not work.

Can any one help me PLEASE?:)


__________________
Sam Powell
Information Systems Officer
Neath Port Talbot College
 
Old December 4th, 2003, 07:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I see your problem:
You're passing variables from SetStartupProperties to ChangeProperty
The thing is, the way you've got ChangeProperty, it doesn't require variables to be passed to it.

So what you need to do is change
Code:
varPropValue = False
to
Code:
varPropValue = True
in your ChangeProperty Function.

The Sub you've got is completely pointless I must say, you could just run the ChangeProperty Function, since that's all that it does anyway.

If you DID want SetStartupProperties() to pass the variables, you'd have to change your ChangeProperty function.
It looks to me like you've copied and pasted the example from the Help file, and then messed around with it.
Paste it back, and don't mess with it, other than to change False to True.
I've pasted it here, with False changed to True just in case:
Code:
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
    ChangeProperty "AllowBypassKey", DB_Boolean, True
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

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
Steven

I am a loud man with a very large hat. This means I am in charge





Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable the [SHIFT Key] on Startup ru1 Access 4 September 22nd, 2007 09:27 PM
Help: Disable the "Shift Key" on macro Auto run ofAlexander Word VBA 1 June 24th, 2007 03:16 AM
Enable Update and Enable Delete check boxes don't mihabib ASP.NET 2.0 Basics 2 December 7th, 2006 11:44 AM
Shift + Enter OR Shift+Double-Click phungleon Access 2 May 20th, 2004 10:14 AM
Trapping the Shift key yossarian Beginning VB 6 2 July 7th, 2003 08:03 PM





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