AutoKeys feature and [Dirty] problem

  • Thread starter Thread starter slickdock
  • Start date Start date
S

slickdock

I put a macro icon on the toolbar that runs a macro with the condition that
if the current record is [Dirty], SaveRecord before continuing with the rest
of the macro.
It works fine when I initiate the macro by clicking the toolbar icon with
the mouse.

I assigned the macro to the F5 key by creating a macro called AutoKeys. But
when I try to access the macro by pressing F5, I get the message: "Can't find
the name [dirty] you entered in the expression. You may have specified a
control that wasn't on the current object without specifying the correct for
or report context."

Thanks in advance for any help.
 
Can anyone help? I hope my question/problem is clear. I am using the
macroname AutoKeys to assign a macroname value when the user presses {F5}.
 
Slickdock,

Please let us know the details of the macro, i.e. actions and arguments, and
any Condition expressions. Thanks.

--
Steve Schapel, Microsoft Access MVP


slickdock said:
Can anyone help? I hope my question/problem is clear. I am using the
macroname AutoKeys to assign a macroname value when the user presses {F5}.

slickdock said:
I put a macro icon on the toolbar that runs a macro with the condition
that
if the current record is [Dirty], SaveRecord before continuing with the
rest
of the macro.
It works fine when I initiate the macro by clicking the toolbar icon with
the mouse.

I assigned the macro to the F5 key by creating a macro called AutoKeys.
But
when I try to access the macro by pressing F5, I get the message: "Can't
find
the name [dirty] you entered in the expression. You may have specified a
control that wasn't on the current object without specifying the correct
for
or report context."

Thanks in advance for any help.
 
Thank you. The macro is called mOpenForm.DA:

1) Condition: [Dirty]
Action: RunCommand, SaveRecord
2) OpenForm: DA, Data Mode: Edit, Window Mode: Normal

When I click with the mouse on the toolbar, it runs fine.

When I press {F5}, it runs macro AutoKeys, which is:

1) MacroName: {F5}
Action: RunMacro, Macro Name: mOpenForm.DA

When I press {F5} to execute the macro, I get the error message:
"DBname can't find the name 'Dirty' you entered in the expression.
You may have specified a control that wasn't on the current object without
specifying the correct for or report context."

So it's like it doesn't recognize that there is a form currently open if I
use {F5}, but it DOES recognize that there is a form open if I use the mouse
to click the icon on the toolbar.





Steve Schapel said:
Slickdock,

Please let us know the details of the macro, i.e. actions and arguments, and
any Condition expressions. Thanks.

--
Steve Schapel, Microsoft Access MVP


slickdock said:
Can anyone help? I hope my question/problem is clear. I am using the
macroname AutoKeys to assign a macroname value when the user presses {F5}.

slickdock said:
I put a macro icon on the toolbar that runs a macro with the condition
that
if the current record is [Dirty], SaveRecord before continuing with the
rest
of the macro.
It works fine when I initiate the macro by clicking the toolbar icon with
the mouse.

I assigned the macro to the F5 key by creating a macro called AutoKeys.
But
when I try to access the macro by pressing F5, I get the message: "Can't
find
the name [dirty] you entered in the expression. You may have specified a
control that wasn't on the current object without specifying the correct
for
or report context."

Thanks in advance for any help.
 
Slickdock,

I have never used this type of construct, so I am not sure. But I think you
would need to change the Condition to something like:
[Forms]![NameOfYourForm].[Dirty]=True

However, the easiest solution might be to just remove the Condition anyway.
It won't do any harm to try and run a SaveRecord even if the record is not
dirty.
 
Thank you. I used to have a simple SaveRecord command instead of the dirty
condition. But the harm in running SaveRecord if its not dirty is when users
with ReadOnly rights are trying to use the database. They get an error if
SaveRecord is part of the command, and they don't have rights to save the
record. That's why I changed it to if Dirty. Since ReadOnly users are never
dirty, the dirty line is ignored by them.

The problem with fully referencing the form name is that the macro may be
initiated at any time, anywhere. So one of 20 or more forms could be
currently open when the macro is initiated. That's why I didn't already solve
the problem by fully referencing the form name in the "dirty" argument.

Any other thoughts?

Steve Schapel said:
Slickdock,

I have never used this type of construct, so I am not sure. But I think you
would need to change the Condition to something like:
[Forms]![NameOfYourForm].[Dirty]=True

However, the easiest solution might be to just remove the Condition anyway.
It won't do any harm to try and run a SaveRecord even if the record is not
dirty.

--
Steve Schapel, Microsoft Access MVP


slickdock said:
Thank you. The macro is called mOpenForm.DA:

1) Condition: [Dirty]
Action: RunCommand, SaveRecord
2) OpenForm: DA, Data Mode: Edit, Window Mode: Normal

When I click with the mouse on the toolbar, it runs fine.

When I press {F5}, it runs macro AutoKeys, which is:

1) MacroName: {F5}
Action: RunMacro, Macro Name: mOpenForm.DA

When I press {F5} to execute the macro, I get the error message:
"DBname can't find the name 'Dirty' you entered in the expression.
You may have specified a control that wasn't on the current object without
specifying the correct for or report context."

So it's like it doesn't recognize that there is a form currently open if I
use {F5}, but it DOES recognize that there is a form open if I use the
mouse
to click the icon on the toolbar.
 
Wow! You can DOOO that???? Thank you! Not only did it work, but I can use
that technique a LOT.

You've helped so much already. But, if you're up to it, do you know where
there may be a list of such ways to reference conditions?

Steve Schapel said:
Slickdock,

Ok, then try it like this...
[Screen].[ActiveForm].[Dirty]=True

--
Steve Schapel, Microsoft Access MVP


slickdock said:
Thank you. I used to have a simple SaveRecord command instead of the
dirty
condition. But the harm in running SaveRecord if its not dirty is when
users
with ReadOnly rights are trying to use the database. They get an error if
SaveRecord is part of the command, and they don't have rights to save the
record. That's why I changed it to if Dirty. Since ReadOnly users are
never
dirty, the dirty line is ignored by them.

The problem with fully referencing the form name is that the macro may be
initiated at any time, anywhere. So one of 20 or more forms could be
currently open when the macro is initiated. That's why I didn't already
solve
the problem by fully referencing the form name in the "dirty" argument.

Any other thoughts?
 
Slickdock,

Happy to know that we've made progress.

I'm afraid I don't know of any documentation on this. If you go into the VB
Editor, and type Screen. then the Intellisense will show you some of the
options available, and many of these will be available also for use in macro
conditions.
 
Back
Top