To Albert D. Kallal

J

John Michael

Thanks for your answer.
I am trying to use your code to dis-able the shift key from a form and am
running into some problems.

Here is your code to disable the shift key.
If IsNull(Me.Text0) = False Then
Dim MyDb As Database
Set MyDb = OpenDatabase(Text0)

MsgBox ("disable set, result = " & ChangeProperty("AllowBypassKey",
dbBoolean, False, MyDb))
End If

I have tried to change it to run the code from within the current db from a
form.
I did so with this code.

Dim MyDb As Database
Set MyDb = CurrentDb
MsgBox ("disable set, result = " & ChangeProperty("AllowBypassKey",
dbBoolean, False, MyDb))

When I run it i get the error:
User defined type not defined for the
Dim MyDb As Database
line of code.

I have tried running it like this
MsgBox ("disable set, result = " & ChangeProperty("AllowBypassKey",
dbBoolean, False))

and uncommenting the
'Set dbs = CurrentDb
in the ChangeProps Module and I get the error:
dbBoolean Variable not defined.

Any ideas will be greatly appreciated.
Thanks in advance. This list is great.

Thanks
John Michael
 
J

Jeff Conrad

Hi,

Albert is on the slopes at the moment so I'll jump in.

It sounds like you need to set a reference to the DAO object library if you are using Access 2000 or
2002. Those versions do not by default set a reference to the DAO library.

To fix the References problem follow these steps:
- Open any module in Design view.
- On the Tools menu, click References.
- Scroll down to you get to Microsoft DAO 3.xx and check it.
- If you're using Access 97 that should be DAO 3.51 Object Library.
- If you're using Access 2000, 2002, or 2003 that should be DAO 3.6 Object Library.
- Close the References box again.
- Now re-compile again. Debug--Compile.
- Hopefully you should not see any more compile errors.

As good practice it may also be better to use this:

Dim MyDb As DAO.Database

....rather than:

Dim MyDb As Database

This helps to avoid confusion for Access (but you still have to manually set a reference to DAO for
2000 and 2002).
 
J

John Michael

Something has changed on my system I guess.
Now whenever I try to run albert's shift bypass key script on any of my db's
I get an error. I have even tried a different copy of his script and still
get the error no matter what db I try it on I get a type mismatch error on
this part of his code in the ChangeProps module.

Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
Evidently when I was trying a lot of different things to figure it out.

It was working before. I tried checking the your suggestion and it doesn't
help.
Any ideas.
thanks
John Michael
 
J

John Michael

Did i somehow change something in one of the DLL's or is this not possible.
I tried sending a true value to dbBoolean when I was trying a lot of diff
scenarios to make it work.
Thanks for your time
JM
 
J

John Michael

this is the code.
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


The part that is causing the problem is in the error section so the
shiftkey2000 db is no longer able to chang a property value and throwing the
error when it tries to create the property.
Do i need to try and delete the property and start over. I would have
thought that the property would be db independent and running the routine on
another db it would work but it now doesn't so something in my micosoft
access setup has changed.


any thoughts.
Thanks
JM
 
D

Douglas J. Steele

How have you declared prp? Since you had the problem with Database previous,
I'm assuming you're using Access 2000 or 2002, and that you kept the ADO
reference when you added the DAO reference using Jeff's advice.

Property is an object in both the ADO and DAO models. Since ADO is higher up
in the list of references, if you simply declared

Dim prp As Property

you'll get an ADO property, when you need a DAO property.

Try

Dim prp As DAO.Property

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset.

To guarantee that you get an ADO object, you'd use

Dim prp As ADODB.Property
 
J

Jeff Conrad

Doug's suggestion should be spot on.
Access is confused between ADO and DAO right now.
Follow his steps and everything should be good.
 
J

John Michael

Originally it did work. I was trying to make it work from within the db
that I wanted it to lock and in trying several different types of
combinations for some reason it quit working. I added

Dim prp As DAO.Property

to it and it started working again. It had quit working before I checked
- If you're using Access 2000, 2002, or 2003 that should be DAO 3.6 Object
Library.
as suggested by Jeff Conrad.
Anyway, it is working again. How would I make it work form within the
application I want to lock.
If you have time.
Thanks for your great help and valuable time.
John Michael
 
A

Albert D. Kallal

Anyway, it is working again. How would I make it work form within the
application I want to lock.

The syntax is:

So, just use:

Dim MyDb As dao.Database

Set MyDb = CurrentDB
ChangeProperty "AllowBypassKey", dbBoolean, False, MyDb

The above would disable the shfit key.
 

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