Disable bypass key in an Access Project

  • Thread starter Thread starter Tom Grillot
  • Start date Start date
T

Tom Grillot

Is there a way to disable/enable the bypass key in an Access Project? I
just recently upsized a running Access application (not a Project) and can't
get the bypass key to stop working.

And along those same lines, why does my dao code suddenly stop working?

Thanks,
Tom
 
Check Access VB Help on the "AllowBypassKey" Property. There are
explanation and sample code in the Help topic.
 
uh, because DAO is crap??

congrats on choosing ADP. it is the best route to go.

but yes, you should rewrite your DAO code from 1995 into ADO.

currentproject.connection is the ADO equivalent to DAO currentdb
 
I guess I didn't make myself clear. I have an Access application (.mdb) for
which I have code that will allow me to toggle the bypass key on or off:
db.Properties("AllowBypassKey") = Not
db.Properties("AllowBypassKey")
with appropriate code to create the property if it hasn't already been
created.

When I upsized the application and rewrote everything with ado I was unable
to find an equivalent way to do this with the ado connection or command
objects. I also tried to just leave the dao code in place (and yes, dao 3.6
is referenced), but Access doesn't seem to recognize the database object:
dim db as dao.database
set db=currentdb
db.Properties(AllowBypassKey) = Not db.Properties(AllowBypassKey)

generates the error message:
.............I'll be damned.....I just reran the code to generate the error
message and it worked. Oh, well.......thanks anyway....
 
I guess I didn't make myself clear. I have an Access application (.mdb) for
which I have code that will allow me to toggle the bypass key on or off:
db.Properties("AllowBypassKey") = Not
db.Properties("AllowBypassKey")
with appropriate code to create the property if it hasn't already been
created.

When I upsized the application and rewrote everything with ado I was unable
to find an equivalent way to do this with the ado connection or command
objects. I also tried to just leave the dao code in place (and yes, dao 3.6
is referenced), but Access doesn't seem to recognize the database object:
dim db as dao.database
set db=currentdb
db.Properties(AllowBypassKey) = Not db.Properties(AllowBypassKey)

generates the error message:
"Object variable or With block Variable not set"

Here's the exact code:

Public Sub DisableShift()
Dim db As DAO.Database
Dim prop As DAO.Property
Const conPropNotFound As Long = 3270

On Error GoTo err_proc

Set db = CurrentDb
db.Properties("AllowBypassKey") = Not
db.Properties("AllowBypassKey")
Set db = Nothing
Exit Sub

err_proc:
If Err = conPropNotFound Then
Set prop = db.CreateProperty("AllowBypassKey", dbBoolean, False)
db.Properties.Append prop
Resume Next
Else
MsgBox Err.Number & ": " & Err.Description
Set db = Nothing
End If
End Sub

PS: If you happened to read my first response to this thread, I canceled
it. Turns out I was testing with the old database.
 
I knew you were using ADP and in ADP, you cannot use CurrentDb. That's why
I referred you to the Help topic which advises to use the
AccessObjectProperties collection of the CurrentProject object.:
 
Thanks. I have to admit I didn't even go there (I'm sure you guessed that).
I assumed it dealt with the dao procedure.

Anyway, I'm going there now and apologize for not checking out your
reference before I responded.

Thanks again,
Tom
 
Hi, I appreciate this is a relatively old message but have a concern!

I have code to toggle the AllowBypassKey property on and off remotely.
Whilst this is useful I am concerned that any other user could use the same
code to hack into my database. Securing the Database or making it MDE has no
effect. Do you think it is possible to make this a setting onw that can only
be done in the currentDB?

Thanks
Rob
 

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

Back
Top