Solved

Disable shift key in .adp

Posted on 2004-09-08
13
856 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
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

808 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