DIsable Shift in adp

  • Thread starter Thread starter Mark
  • Start date Start date
I found the answer and much simplier than I thought.
Call the this:
CurrentProject.Properties.Add "AllowBypassKey", False
Or to reset it:
CurrentProject.Properties.Add "AllowBypassKey", True

Why so many examples with a lot of code showing the process when it's really
simple?
M
 
Well, it's really not that simple...

AllowBypassKey does not exist as a db property. The first time you set it,
you must create it. That's why most examples show an error trap like this
example:
Private Sub ChangeProperty(strPropertyName As String, _
varPropertyType As Variant, bolPropertyValue As Boolean)
Dim db As DAO.Database

On Error GoTo ErrorHandler

Set db = CurrentDB

db.Properties(strPropertyName) = bolPropertyValue

exit_ChangeProperty:
Set db = Nothing
Exit Sub

ErrorHandler:
'If property not found, create it.
If Err = 3270 Then
Dim prpNew As DAO.Property
Set prpNew = db.CreateProperty(strPropertyName, varPropertyType, _
bolPropertyValue, True)
db.Properties.Append prpNew
Else
MsgBox Err.DESCRIPTION, vbCritical
End If

End Sub
 
I created a simple conditional statement in response to a msg box. One way it
gets set to True and the other to False. I see no problems with it. My
research shows some examples in DAO using 4 or 5 functions! (which of course
I couldn’t get to work for me). I don’t understand the need for so much code.
Maybe it is much simpler with ADO, and DAO is significantly different.
Thanks,
M
 
Again...If you try to set AllowBypassKey for the FIRST time (no matter how
you set it), it will error out. You have to create it first.

Using a generic function like I posted lets you set any property you want.

And you are right about DAO vs. ADO. Some tasks take less code in DAO, some
take more.
 

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