AllowByPassKey

G

germainHuberdeau

When I try to execute the AllowBypassKey function further below I get the
following error

=> object variable or with block variable not set

Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub

Function ChangeProperty(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
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
 
D

Douglas J. Steele

Not sure whether this is the problem, but your declaration should be

Dim dbs As DAO.Database, prp As DAO.Property

If that doesn't solve the problem, try single-stepping through the code to
identify the exact line that's raising the error.
 
G

germainHuberdeau

Thanks for your reply.

I also had previously tried the Dim dbs As DAO.Database, prp As DAO.Property
( I had to add the reference MS 3.6 object in the library.)

I tried many variation of solutions from different programmers with
basically the same coding. I stepped through the code everytime to see where
it err's and for all of them I get the same error on the following code
statements:

dbs.Properties(strPropName) = varPropValue
and
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
 
G

germainHuberdeau

Yes I still get the error, I downloaded the solution from the link you
provided below. I will give this a try and let you know how it goes. Again
thanks for your assistance. gh
 
G

germainHuberdeau

From what I can tell the solutions I've been trying is for mdb file types,
I'm looking for a solution for an adp file type. Which uses a add method vs
the append. Therefore the createProperty won't work, I need to add it to
AccessObjectProperties of the current project.

Therefore I'm looking for the syntax code for adp file type.
 
J

James A. Fortune

germainHuberdeau said:
From what I can tell the solutions I've been trying is for mdb file types,
I'm looking for a solution for an adp file type. Which uses a add method vs
the append. Therefore the createProperty won't work, I need to add it to
AccessObjectProperties of the current project.

Therefore I'm looking for the syntax code for adp file type.

Recently, in CDMA, Lyle posted:

http://groups.google.com/group/comp.databases.ms-access/msg/f91babd5fb038d3c

Post back if it doesn't work for adp's as claimed.

James A. Fortune
(e-mail address removed)
 

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