Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Dim As Database type - diabling shift key in Access 2000 1

Status
Not open for further replies.

StarScream

Technical User
Oct 10, 2001
46
US
I've read the FAQ on Enabling/Disabling the Shift Key on Startup. However, it was written for Access 97 and I'm using Access 2000. I get an error that the "User-defined type is undefined". Can't Dim As Database.

Code:
Public Sub EnableByPassKeyProperty()
Dim db As Database
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
End Sub

Can anyone help me out? Thanks.

PJ
 
I had this problem before. This is how I fixed mine:

In the Visual Basic editor, click the 'references' option on the menu bar.

Make sure that you have 'Microsoft DAO 3.6 Object Library' checked.

 
ok Starscream

I had this problem, exactly the same as you have described. It took a while for an amature like me to track this down but I know that this works.
copy this into a module

'This Code Disables the Shift Key
'
Public Function DisableShiftKey() As Boolean
Set prp = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, False, True)
CurrentDb.Properties.Append prp
Set prp = Nothing
MsgBox "Shift Key Dis-abled", vbCritical + vbOKOnly, "Steady Says ..."

End Function

place your cursor in the code somewhere and press F5

when you run this ONCE it does what it says on the box and Disables the shift key. Exit Access and try to use the shift key to break the startup routine and it won't work. So you need to put a button somewhere in a secret place to Re-Enable the shift key - because the code above is PERMANENT untill you tell it otherwise !!


Put this in a function or behind a button :- (I've copied this from my function)

'This Code Re-enables the Shift Key
'
Public Function EnableShiftKey()
CurrentDb.Properties.Delete "AllowBypassKey"
MsgBox "Shift Key En-abled", vbCritical + vbOKOnly, "Steady Says ..."
End Function

so you know that you can re-enable because you can guarantee you're going to need to ...
Quit Access and then use the shift key to do your deed.

Solo7 ...

btw the code you and I both copied doesn't run correctly as the "EnableByPassKeyProperty" should be a BOOLEAN property.
Hope this helps
 
Solo7, Beren1h,

I tried what you said but keep getting an error "Object not found in this collection."

I checked the DAO 3.6 Library like Beren1h said and still the error.

I have both codes as modules. I call them from hidden buttons.

Any ideas?

PJ
 
I use 5 references (generally), but it does vary :-
btw this is Access2K


1)Visual Basic For Applications
2)Microsoft Access 9.0 Object Library
3)OLE Automation
4)Microsoft ActiveX Data Objects 2.1 Library
5)Microsoft DAO 3.6 Object Library

Solo7 ...
 
Hmmm...maybe it wasn't the DAO 3.6

The only one I have checked that you haven't listed is

'Microsoft Visual Basic for Applications Extensibility 5.3'


give that a shot?
 
I have all of those ones checked.

I get this line
Code:
    CurrentDb.Properties.Delete "AllowBypassKey"
to produce the "Item not found in this collection" error.

Do I have to run the "Disable Shift Key" code first? Could that be why I am getting this error?

PJ
 
I beleive you have to disable before the enable will work. Try it on a backup copy first, dont want to lock your only copy of the DB. Zorro
 
I realized that after looking at the code more closely -- it was trying to delete a property that hadn't been set yet. Thanks.

After testing though, I found a loop hole I'd like to fix. When you open the db the first time, the shift key won't work (thats the whole idea!). But when you close out of the db with Access still open, then go to File | Open and select that same db. It opens up the entire screen with all the tables, forms, reports, etc. Thats not good.

Anything you can think of to fix this?

PJ
 
Well, there are other ways to get into the database design, besides holding down the shift key. Make sure you have disabled all of them.

What I do is run a quick start up routine when the database opens that disables all the back doors. (Unless I'm the one opening the database). The routine then automatically closes and re-opens the database in order to activate the newly created properties.

Here is a link to the code for the start up routine. faq181-1172 Maq B-)
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top