stop macro before opening report from form

T

thread

hi all,
i have report that i can open from ususal switchboard and from a form.
when its working from switchboad its opening with a macro another form
that depending on this data is giving information.
when i'm opeing a form and trying from the form to open the report i
dont want the macro to open this additional form becaouse i have
already the data on the relevant form.
i tryed to give condition on the where condition on the
form:"isnull(...) but still it doesnt work
 
A

Allen Browne

Put this expression into the Macro Conditions column of your macro, beside
the action you want to suppress:
SysCmd(acSysCmdGetObjectState, acForm, "Form1") <> 0

This tests whether Form1 is open. Replace the "Form1" with the name of your
form (and include the quotes.)

If you don't see a MacroCondition column in macro design, it's on the View
menu.
 
T

thread

from some reason the formula does not work,its raising error,
are you sure it should be in the macro design?
Allen Browne כתב:
 
A

Allen Browne

SysCmd() is a built-in function.
You can use it in a macro.
(Not in the Action column though.)

You can test further by opening the Immediate Window (Ctrl+G), and entering:
? SysCmd(acSysCmdGetObjectState, acForm, "Form1")
When you press enter, it should respond with a zero if Form1 is not open.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

from some reason the formula does not work,its raising error,
are you sure it should be in the macro design?
Allen Browne ???:
 
T

thread

from some reason the macro is not responding to the marco condition its
been ignored

Allen Browne כתב:
 
T

thread

i think i will convert the macro to a vba code but do you know maybe
how can filter the query when it suppose to be filtered from 2 diffrent
forms every time?
 
A

Allen Browne

You cannot have the names of 2 different forms in the query, and have it use
only one of them.

Instead, use leave the criteria out of the query, and use the Filter of the
form, or the WhereCondition of OpenReport.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

i think i will convert the macro to a vba code but do you know maybe
how can filter the query when it suppose to be filtered from 2 diffrent
forms every time?
 
T

thread

its a problrm to take out the criteria from the query becaouse the
reports(48 of them) are basing on one query ,in order to take it out i
need to update 48 reports,its making it more heavy or make 1 modular
report but it takes time.
how can i disable the macros and dinamicly update the criteria of the
query?
Allen Browne כתב:
 
A

Allen Browne

If you remove the criteria from the report, you can use the WhereCondition
of OpenReport. Unless your reports refer to the query parameters, they don't
need to be changed.

Examples of using the WhereCondition:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
and:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

its a problrm to take out the criteria from the query becaouse the
reports(48 of them) are basing on one query ,in order to take it out i
need to update 48 reports,its making it more heavy or make 1 modular
report but it takes time.
how can i disable the macros and dinamicly update the criteria of the
query?
Allen Browne ???:
 
T

thread

thank you very much,the tips that you gave me helped me,i took out the
filter and converted all the macto commands to vba that solve the
problem
 
Top