Solved

Disable shift key in .adp

Posted on 2004-09-08
13
860 Views
Last Modified: 2008-02-01
I picked up the following code from another post, "Database" is not recognized in the Dim statement.  I'm using Access XP and i a BIG hurry.  I need the answer within the hour.  Is there something else I need to use in an adp?  Please help.

Function BackDoor(rbFlag As Boolean) As Integer
On Error GoTo BackDoor_Error

'  ?BackDoor(True)  'Enables the Shift Key bypass
'  ?BackDoor(False) 'Disables the Shift Key bypass
'-------------------------------------------

Dim db As Database
Set db = CurrentDb
db.Properties!AllowBypassKey = rbFlag

BackDoor_Exit:
   Exit Function
   
BackDoor_Error:
   If Err = 3270 Then
      'AllowBybassKey property does not exist
      db.Properties.Append _
         db.CreateProperty("AllowBypassKey", _
         dbBoolean, rbFlag)
      Resume Next
   Else
      'Some other error
      MsgBox "Unexpected error: " & Error$ & " (" & Err & ")"
      Resume BackDoor_Exit
   End If

Just press CTRL-G to activate the Debug window and type the function as follows:

   Backdoor(False)

will disable the Shift key bypass.

   Backdoor(True)

will enable it again.

In your database's Startup Options (Tools, Startup) you need to make sure the Use Access Special Keys option is checked so you have the ability to press CTRL-G to run your function.  You can use the AutoKeys macro to disable the F11 key so the user's can't open the Database Window.
0
Comment
Question by:stillgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006172
Dunno if this works with ADPs, but you could try:

Dim db As Object

Set db = CurrentProject
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006192
I didn't read yoru Q properly, but...

Leave the CurrentProject line out, and that should fix it. If it doesn't, add a reference to DAO (Tools->References, check Microsoft DAO 3.5). Change the line to:
Dim db As DAO.Database
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006203
Or DAO 3.6....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:stillgar
ID: 12006368
Adding the reference got the Database.  Now I get the error Object Variable or With BLock Variable not set.  It errors at the point of my Set statement.  It is not able to set to CurrentDB or CurrentProject.  
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006406
How about:
Set db As Object

?
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006410
Sorry:

Dim db As Object
0
 

Author Comment

by:stillgar
ID: 12006593
Using:
Dim as Object
Set db = CurrentProject

I get a new error:

Error#2455  You entered an expression that has an invalid reference to the property 'AllowBypassKey'

AllowBypassKey does not show up as a property of CurrentProject in intellisense, but it gives me back the error saying it was an invalid reference to the property.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006624
Hmm - try changing this line:
If Err = 3270 Then

To:
If Err = 2455 Then
0
 

Author Comment

by:stillgar
ID: 12006704
No luck
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12006898
0
 

Author Comment

by:stillgar
ID: 12007552
Thanks a million.  That was just what I needed.

Here is the final function

Public Function Backdoor(Enable As Boolean)
'Backdoor(True) = Disable shift key
'Backdoor(False) = Enable shift key

On Error GoTo BackDoor_Error
'Change the value of the property
    CurrentProject.Properties("AllowBypassKey"). _
        Value = Enable
       
BackDoor_Exit:
MsgBox "Changed to " & Enable
   Exit Function
       
BackDoor_Error:
'If the property has not been added, then add it and set it
'to the value specified in the function (true/ false)
    If Err.Number = 2455 Then
        CurrentProject.Properties.Add "AllowBypassKey", Enable
    Else
        MsgBox "Unexpected error: " & Error$ & " (" & Err.Number & ")"
    End If
       
    Err.Clear

End Function
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12007620
No problem, glad I could help!
0
 

Author Comment

by:stillgar
ID: 12007758
Ack!
Be careful of the comments in the first section!
I switched up backdoor(True/ False).
True opens the backdoor.  False locks it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question