Controlling the SHIFT Key when starting an Access Applicatio

Joozh

Board Regular
Joined
Dec 30, 2002
Messages
114
Hi,

I read somewhere (long time back) that we can control the SHIFT Key's behaviour when starting an Access application...

Can someone provide me with the code to disable AND enable the shift key.

I'll appreciate your help.

Cheers
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I usually use something like the below function. I just modified it from the link below...<pre><font color='#000000'><font color='#000080'>Function</font> ToggleShift(Optional fAllowShift<font color='#000080'>As</font> Boolean = False)<font color='#008000'>'This function will disable (or enable) the shift at startup causing</font><font color='#008000'>'the Autoexec macro and Startup properties to always be executed (or not)</font>

On Error<font color='#000080'>GoTo</font> errToggleShift<font color='#000080'>Dim</font> db<font color='#000080'>As</font> DAO.Database<font color='#000080'>Dim</font> prop<font color='#000080'>As</font> Property
Const conPropNotFound = 3270<font color='#000080'>Set</font> db = CurrentDb()<font color='#008000'>'This next line disables the shift key on startup.</font>
db.Properties("AllowByPassKey") = fAllowShift<font color='#008000'>'function successful</font>

ExitHere:<font color='#000080'>Exit</font><font color='#000080'>Function</font>

errToggleShift:<font color='#008000'>'The first part of this error routine creates the "AllowByPassKey</font><font color='#008000'>'property if it does not exist.</font><font color='#000080'>If</font> Err = conPropNotFound<font color='#000080'>Then</font><font color='#000080'>Set</font> prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, fAllowShift)
db.Properties.Append prop
Resume ExitHere<font color='#000080'>Else</font>
MsgBox "Function 'ToggleShift' did not complete successfully."
Resume ExitHere<font color='#000080'>End</font><font color='#000080'>If</font><font color='#000080'>End</font><font color='#000080'>Function</font></font></pre>

This was modified from http://www.tek-tips.com/gfaqs.cfm/lev2/4/lev3/27/pid/181/fid/93

To use this to Disable the shift key, call it like this:

ToggleShift
or
ToggleShift False
or
Call ToggleShift(False)

To Enable the shift key after you have disabled it,

ToggleShift True

or

Call ToggleShift(True)

HTH,

Russell
This message was edited by Russell Hauf on 2003-01-09 01:51
 
Upvote 0
Hi,

Thanks for the reply. I'll try out the code to disable the SHIFT key. Can you also kindly assist me in the code to ENABLE the SHIFT key.

Thanks :)
 
Upvote 0
Ooppps,

Sorry. I posted the reply without going through your complete reply. I'll try out your suggestion; it appears that it has solutions for BOTH options i.e. disabling as well as enabling the shift key.

Cheers :)
 
Upvote 0
Russel,

I ran into a problem while trying to use your suggested solution.

I want to place the code in a separate MDB; from which I want to disbale or enable the Shift key of barious access databases (rather than placing the code in the mdb while I am trying to protect).

Instead of the following statement (from your solution):
Set db = CurrentDb()

I tried using something like:
Set db = "C:TempMyDB.mdb"

but get a compilation error.

I hope my requirement is clear. I'll appreciate your help.

Thanks
 
Upvote 0
Re: Controlling the SHIFT Key when starting an Access Applic

Old but useful post - so I'm going to Bump it.
I did have one problem running this. Got a type mismatch on this line.

Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, fAllowShift)


And, as soon as I changed this declaration

Dim prop As Property

To this:

Dim prop As DAO.Property


It worked like a charm. Thanks! Like yours better Russell. One function to do both.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,837
Messages
6,162,282
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top