A Newbie Question

  • Thread starter Thread starter benjamin
  • Start date Start date
B

benjamin

I am new to MS Access and needs to know how to do conditional macros in a
big hurry for my school project. Does anybody know where i can find some
internet resources for conditional macros?

Thanks in advance.
 
The Condition column is the place where you put conditional expressions
that, if true, cause that action of the macro to be executed. Check it out
in Help.
 
Thanks for the quick reply.

I have been digging into the help file for a night but can't really make
sense of it. Is it possible to use "if...then...else" in macros?

Thanks
 
take a look at the IIf() function in Help.


benjamin said:
Thanks for the quick reply.

I have been digging into the help file for a night but can't really make
sense of it. Is it possible to use "if...then...else" in macros?

Thanks

in
 
In addition to tina's suggestion, you can use "levels" of conditions in a
macro by this type of structure (example assumes that you're using the value
of a textbox (named txtBox) on a form (named FormName) as the decision
maker:

Condition: Forms!FormName!txtBox = 10
Action: SetValue
Control Name: Forms!FormName!txtBoxNewOne
Expression: 12

Condition: . . .
Action: StopMacro

Condition: (blank)
Action: SetValue
Control Name: Forms!FormName!txtBoxNewOne
Expression: 19

This is similar to an If..Then...Else structure. If the textbox contains the
value of 10, the macro will do the first SetValue action and, because of the
three dots in the Condition column for the second action (StopMacro), it
will do that action too. If the textbox contains a value other than 10, the
macro jumps to the first action whose Condition cell does not contain the
three dots.

--

Ken Snell
<MS ACCESS MVP>
 
Thank you. I understand how it works now.

Just one more question, is it possible to check if my subform is returning
results when i requery it using macro? Cos this is the real headache now.

Thank you once again, and thanks to Tina too.
 
Sure. Use a condition expression similar to this:

Condition: DCount("*", Forms!FormName!SubformName.Form.RecordSource) = 0
Action: MsgBox
Message: There are no records in the subform.

Note that SubformName must be the name of the subform control (the control
on the main form that actually holds the subform), which may or may not be
the same name as that control's SourceObject (the form that is being used as
the subform).
 
Back
Top