Bypass Startup Keys - Code stopped working

S

Stuart Kirk

I've used the standard MS Helpfile code to change the startup properties in
just about every database I've written in the last 7 years.

Suddenly I have produced a database in Access 2002 where it doesn't work.

I've checked all the references, I've even changed the code to Michael
Kaplan's version off the Access Web and it still doesn't work.

Bizzarly, I have created a new Test Database, also in Access 2002, I cut and
Pasted the code across, and it does work!!!

Does anyone know of any Gotchas that I haven't run into yet??

I have every version of access loaded from Access 97 to Access 2002, and I'm
running Windows 2000 Professional.

Many thanks in anticipation.

Stuart
 
S

Stuart Kirk

Thanks for the reply Allen

but I'm already Serviced packed (1 and 2) and I don't have 'Windows in
Taskbar' ticked.

the 2 functions I now use are pasted below, and you will notice that the 2nd
function is copied directly from the Access Web courtesy of Michael Kaplan.

I have checked the values of all the properties thus created in the debug
window and all seems OK.
Also, I can change things manually and then run the code and see that things
have been set properly.

Bizzare, but I have now created 2 seemingly identical databases where in one
the code works and in the other it doesn't.

Any help would be greatly appreciated.

Function SetStartupProperties(Optional which As Boolean)
On Error GoTo err_Handler

ChangePropertyDdl "StartupForm", dbText, "MainMenu"
ChangePropertyDdl "StartupShowDBWindow", dbBoolean, which
ChangePropertyDdl "StartupShowStatusBar", dbBoolean, True
ChangePropertyDdl "AllowShortcutMenus", dbBoolean, which
ChangePropertyDdl "AllowBypassKeys", dbBoolean, which
ChangePropertyDdl "AllowBreakIntoCode", dbBoolean, which
ChangePropertyDdl "AllowBuiltinToolbars", dbBoolean, which
ChangePropertyDdl "AllowFullMenus", dbBoolean, which
ChangePropertyDdl "AllowSpecialKeys", dbBoolean, which
ChangePropertyDdl "AllowToolbarChanges", dbBoolean, which
ChangePropertyDdl "Auto Compact", dbInteger, 1
ChangePropertyDdl "AppTitle", dbText, conAppName

exit_Handler:
Exit Function

err_Handler:
Err.Clear
Resume exit_Handler

End Function

Function ChangePropertyDdl(stPropName As String, PropType As
DAO.DataTypeEnum, vPropVal As Variant) As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangePropertyDdl_Err

Dim db As DAO.Database
Dim prp As DAO.Property

Const conPropNotFoundError = 3270

Set db = CurrentDb
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
db.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, PropType, vPropVal, True)
db.Properties.Append prp

' If we made it this far, it worked!
ChangePropertyDdl = True

ChangePropertyDdl_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function

ChangePropertyDdl_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangePropertyDdl_Exit
End Function
 
A

Allen Browne

Did you try deleting the database's Properties("AllowBypassKey")?

That way your code will recreate it with the correct data type.
 
S

Stuart Kirk

Yes, Micheals code does that, but I am assuming that the correct property
type in this case is Boolean

Thanks again

Stuart
 
R

Ron Hinds

Stuart Kirk said:
Yes, Micheals code does that, but I am assuming that the correct property
type in this case is Boolean

Thanks again

Stuart

Correct me if I'm wrong, but I never hear dof a Boolean value called
"which":

 
B

Brendan Reynolds \(MVP\)

It's in the bit you snipped, Ron ...

Function SetStartupProperties(Optional which As Boolean)
 
S

Stuart Kirk

Thanks for all that but I've still got the problem!!

I've now tried it on a different machine as well, and still I have two
databases, one that the code works and one that it doesn't.

Not only is the BypassKey not working so is the AllowShortcutMenus.

Any ideas would be appreciated.

Thanks

Stuart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top