Check for condition first

  • Thread starter Thread starter David French
  • Start date Start date
D

David French

I have the need to create a macro that runs a particular report.
The condition is that I need it to run ONLY if a particular range of
customer numbers is present.
For example the batch number DC12345 will have customer numbers beginning
with an 'R' where DC54321 will not.
My current macro runs on whatever 'DC' number is displayed in the field.
The new macro needs to be choosy and send a message box if there are no 'R'
customers.

Dave
 
David,
Here is one possible approach to this. Use a Condition in the macro,
which might look like this...
DCount("*","YourQuery","[CustNo] Like 'R*'")>0
Action: OpenReport
DCount("*","YourQuery","[CustNo] Like 'R*'")=0
Action: MsgBox
 
Are you utilizing an actual Macro or VBA code to accomplish your example?

Dave

Steve Schapel said:
David,
Here is one possible approach to this. Use a Condition in the macro,
which might look like this...
DCount("*","YourQuery","[CustNo] Like 'R*'")>0
Action: OpenReport
DCount("*","YourQuery","[CustNo] Like 'R*'")=0
Action: MsgBox

--
Steve Schapel, Microsoft Access MVP


David said:
I have the need to create a macro that runs a particular report.
The condition is that I need it to run ONLY if a particular range of
customer numbers is present.
For example the batch number DC12345 will have customer numbers beginning
with an 'R' where DC54321 will not.
My current macro runs on whatever 'DC' number is displayed in the field.
The new macro needs to be choosy and send a message box if there are no 'R'
customers.

Dave
 
Dave,

I am referring to a macro. In the macro design window, if you can't see
a Condition column, you might need to select Conditions from the View
menu. You will have to substitute the name of your actual query (i.e.
the query that the report is based on) instead of "YourQuery", and you
will have to substitute your actual customer number field name instead
of [CustNo] in my example. Make sense?
 
Thanks Steve!!
That was the ticket! I never knew there was a 'Condition' column. That
just opens up a whole new WORLD of possibilities!
I have it set to check for that first the presence of "R" accounts. If it
finds none then it gives the message box. If there are "R" accounts then
the first commands are ignored and goes on to execute the report I need.
I really LOVE these Newsgroups!!

Dave French

Steve Schapel said:
Dave,

I am referring to a macro. In the macro design window, if you can't see
a Condition column, you might need to select Conditions from the View
menu. You will have to substitute the name of your actual query (i.e.
the query that the report is based on) instead of "YourQuery", and you
will have to substitute your actual customer number field name instead
of [CustNo] in my example. Make sense?

--
Steve Schapel, Microsoft Access MVP

David said:
Are you utilizing an actual Macro or VBA code to accomplish your example?

Dave

news:u3S#[email protected]...
 
Dave,

Happy to see a door opening for you. You can set whether the Condition
column of a macro always shows under the Tools|Options|View menu of the
database. I have never really understood why Microsoft chose to hide it
by default.
 
Back
Top