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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AllowByPassKeys 2

Status
Not open for further replies.

ChrisTheAncient

Technical User
Dec 22, 2002
169
0
0
GB

Please excuse me being in extremely dense mode - it's been a long day!

Running Access XP.

I've seen all sorts of things about how AllowBypassKeys will prevent a user seeing the database window by holding <shift> as they open the database. I've even read the code and instructions on the help page in the code section.

I've also read variations on a theme for the code and they all seem slightly different in places.

I've read all sorts in the various forums. But none of it down to my level (simple vba coding in some of the modules).

So, here's the stoopid bit of me. Where do actually I put whatcode and how?

Please put it in words of one syllable or less because I'm very old and tired!

TIA

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
I use Access 97 and 2000. Straight from ACCESS 97 help, don't know if applicable to Access XP -

You can use the AllowBypassKey property to specify whether or not the SHIFT key is enabled for bypassing the startup properties and the AutoExec macro. For example, you can set the AllowBypassKey property to False to prevent a user from bypassing the startup properties and the AutoExec macro.

Setting

The AllowBypassKey property uses the following settings.

Setting Description
True (–1) Enable the SHIFT key to allow the user to bypass the startup properties and the AutoExec macro.
False (0) Disable the SHIFT key to prevent the user from bypassing the startup properties and the AutoExec macro.
You can set this property by using a macro or Visual Basic.
To set the AllowBypassKey property by using a macro or Visual Basic, you must create the property by using the CreateProperty method and append it to the Properties collection of the Database object.

Remarks

You should make sure the AllowBypassKey property is set to True when debugging an application.
This property's setting doesn't take effect until the next time the application database opens.




And this is the related example -

The following example shows a procedure named SetStartupProperties that passes the name of the property to be set, its data type, and its desired setting. The general purpose procedure ChangeProperty attempts to set the startup property and, if the property isn't found, uses the CreateProperty method to append it to the Properties collection of the Database object. This is necessary because these properties don't appear in the Properties collection until they've been set or changed at least once.

Sub SetStartupProperties()
ChangeProperty &quot;StartupForm&quot;, dbText, &quot;Customers&quot;
ChangeProperty &quot;StartupShowDBWindow&quot;, dbBoolean, False
ChangeProperty &quot;StartupShowStatusBar&quot;, dbBoolean, False
ChangeProperty &quot;AllowBuiltinToolbars&quot;, dbBoolean, False
ChangeProperty &quot;AllowFullMenus&quot;, dbBoolean, True
ChangeProperty &quot;AllowBreakIntoCode&quot;, dbBoolean, False
ChangeProperty &quot;AllowSpecialKeys&quot;, dbBoolean, True
ChangeProperty &quot;AllowBypassKey&quot;, dbBoolean, True

End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
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
 

Gee, thanks!

wabeb...

That link to Extreme Visual Basic was a dream and I downloaded the little application and it's done the job.

mMany, many thanks. I have managed to refrain from pulling out all of my hair.

jdemmer...

Lovely write up - which I shall print and keep because it is really helping my learning processes in vba. So, many, many thanks for that as well.

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Your most welcome....now where is my STAR!!! LOL!!



:)WB
 
wabeg

Humble apologies. I was so over the moon at getting a fix, I forgot.

So here it is...

Many thanks

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
And one for jdemmer for giving me so much useful background info!

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top