Conditional Macro

  • Thread starter richnida via AccessMonster.com
  • Start date
R

richnida via AccessMonster.com

I have a form that has three fields and the data that is entered in these
fields will cause a text string to be entered into the subForm field [field4].


[field1] is a Yes/No response
[field2] text entered is either “ENL” or “OFF” or “DUAL”
[field3] text entered is either “NO RCD” or “PULL” or “REMARKS”

The macro is set to the After Update properties for [field3] of which I
created a conditional macro that would “GoToControl” and “SetValue” for five
different situations.

Based on the information that is recorded into [field1], [field2], or [field3]
will place either one of the following text string into [field4]

"CREATE ENL RCD"
"CREATE OFF RCD"
"CREATE DUAL OFF RCD"
"CREATE DUAL ENL RCD"
"PULL REPORT"

The following is the first and second condition:

First Condition: (GoToControl [field3])
[Forms]![frmNameSSN].[Form]![field1]=No And [Forms]![frmNameSSN].[Form]!
[field2]="ENL" And [Forms]![frmNameSSN].[Form]![field3]="NO RCD"

SetValue:
Item: [Forms]![frmNameSSN]![subfrmErr103List].[Form]![ field4]
Expression: "CREATE ENL RCD"

Second Condition: (GoToControl [field3])
[Forms]![frmNameSSN].[Form]![field1]=Yes And [frmNameSSN].[Form]![field2]
="OFF" And
[frmNameSSN].[Form]![field3]="NO RCD"

SetValue:
[Forms]![frmNameSSN]![subfrmErr103List].[Form]![ field4]
"CREATE OFF RCD"

How can I get this to work when I enter something into one of the three
fields, it will change the fourth field accordingly? I was assuming that then
one of the conditionals is false it would move to the next condition.

Thanks,
 
S

Steve Schapel

Richnida,

I can't really see the purpose of the GoToControl actions in your macro.

However, since you have 2 actions for each Condition, you will need to
enter an ellipsis (...) into the Condition column for the second action,
to indicate that the same condition applies as in the immediately above
action. Have you already got this?

Other than this, I'm not sure what the problem is, since you didn't say
what is happening that is different from what you need or expect.

By the way, as an aside, your Condition statements could be written a
lot more simply, since the macro is being run from an event on the same
form as you controls. For example...

Condition: [field1]=No And [field2]="ENL" And [field3]="NO RCD"
Action: SetValue
Item: [subfrmErr103List]![field4]
Expression: "CREATE ENL RCD"
 
R

richnida via AccessMonster.com

Steve, Thanks alot, yes I had the ellipsis under the Condition column, and on
the SetValue row. I changed the macro based on your example and it works
great. I have already added some other conditions - just great - thanks again.


Richard

Steve said:
Richnida,

I can't really see the purpose of the GoToControl actions in your macro.

However, since you have 2 actions for each Condition, you will need to
enter an ellipsis (...) into the Condition column for the second action,
to indicate that the same condition applies as in the immediately above
action. Have you already got this?

Other than this, I'm not sure what the problem is, since you didn't say
what is happening that is different from what you need or expect.

By the way, as an aside, your Condition statements could be written a
lot more simply, since the macro is being run from an event on the same
form as you controls. For example...

Condition: [field1]=No And [field2]="ENL" And [field3]="NO RCD"
Action: SetValue
Item: [subfrmErr103List]![field4]
Expression: "CREATE ENL RCD"
I have a form that has three fields and the data that is entered in these
fields will cause a text string to be entered into the subForm field [field4].
[quoted text clipped - 40 lines]
 

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

Top