autoexec macro

J

jn

can someone show me the correct syntax for indicating
function name and arguments in a macro?

am trying to disable allowbypasskey in an autoexec macro.

have keyed the code that is on the web. the function name
is changeproperty. when i key changeproperty() in the
function area, i get the message 'incorrect number of
arguments'. when i key changeproperty(strpropname,
varproptype, varpropvalue), i get the message can not find
strpropname.
so do not understand why the problem.

thanks
 
S

Steve Schapel

jn,

A few issues here...

First of all, you forgot to mention what macro action(s) you are using
in your AutoExec macro. I assume one of them is RunCode?

I am not sure what code you are using, but if the function requires
arguments, you will have to supply values for them. Stuff like
strpropname etc sound like variables, which will not be applicable
within the macro. You need to either set up the function so the
argument values are supplied or optional.

But perhaps most importantly, there's not much point in doing this in
the AutoExec macro anyway. Once the AutoExec runs, it's too late
anyway, and if the user uses the bypass key, the AutoExec doesn't run,
so what's the point?

- Steve Schapel, Microsoft Access MVP
 
S

steve schapel

hi, yes the statement is run code.

what i trying to accomplish is to prevent users from using
the shift key at startup.
i was directed to website
wwww.mvps.org/access/general/gen0040.htm for code that
dealt with securing allowbypasskey.

that code follows:
Function changepropertyddl(stpropname As String, proptype
As DAO.DataTypeEnum, vpropval As Variant) As Boolean
On Error GoTo changepropertyddl_err

Dim db As DAO.Database
Dim prp As DAO.Property
Const conpropnotfounderror = 3270

Set db = CurrentDb
db.Properties.Delete strpropname
Set prp = db.CreateProperty(stpropname, proptype,
vpropval, True)
changepropertyddl = True

changepropertyddl_exit:
Set prp = Nothing
Set db = Nothing
Exit Function
changepropertyddl_err:

If Err.Number = conpropnotfounderror Then
Resume Next

End If
Resume changepropertyddl_exit
End Function

this code is in a module in access. i have a macro named
autoexec that has runcode statement. that runcode
statement points to the above function. that function name
is in the box at the bottom of the screen when you select
runcode.

when i put the name as changepropertyddl(), i get the msg
of incorrect arguments at startup. if i put names inside
the parens that are in the function, i get the msg can not
find the specific names.

as i indicated earlier, i can not find syntax anywhere on
to code the function for the runcode statement.


i also tried using keycodes for the shift key and that did
not work.

if you know a better way, it would be greatly appreciated.

thanks

john
 
S

Steve Schapel

John,

It is pointless putting this in an AutoExec macro. If the user uses
the Bypass key, the AutoExec macro does not happen, so therefore it
will not disallow the bypass key. If the user does not use the Bypass
key, the AutoExec macro will happen, the bypass key will be
disabled... but he didn't use it anyway!

Anyway, if you want to do this in code, you will need another function
based on the first. This code is general code regarding database
properties. As I mentioned before, the macro doesn't know which
values to assign to the variables. I have not tried this, but I think
something like this should work...
Public Function DisableBypass()
changepropertyddl("AllowBypassKey", DB_Boolean, False)
End Function
.... then run this function with your RunCode macro.

- Steve Schapel, Microsoft Access MVP
 

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

Similar Threads


Top