Macro - Set Value

M

Matt

I'm trying to create a macro that will update a field in a form on the basis
of the value of another field. For example: If someone selects CategoryID 1
a checkbox will update to Yes. The same is true if someone selects
CategoryID 2 and 5. But if CategoryID 4 is selected I want the checkbox to
remained unchecked.

Thank you in advance.
 
F

fredg

I'm trying to create a macro that will update a field in a form on the basis
of the value of another field. For example: If someone selects CategoryID 1
a checkbox will update to Yes. The same is true if someone selects
CategoryID 2 and 5. But if CategoryID 4 is selected I want the checkbox to
remained unchecked.

Thank you in advance.

It's simpler using code.
Is the choice limited to just these numbers?
But what about 3?
I'll assume 3 and 4 are both No, and the choice is limited to these 5
numbers.

In the [CategoryID] AfterUpdate event and in the Form's Current event,
write:

If Me![CategoryID] = 3 Or Me![CategoryID] = 4 Then
[CheckBoxName] = False
Else
[CheckBoxName] = True
End If
 
K

Ken Snell [MVP]

Couple of ways this can be done via a macro:

(1) use just the SetValue action (no condition)

Action: SetValue
Item: Forms!FormName!CheckboxName
Expression: (Forms!FormName!CategoryID = 1 Or
Forms!FormName!CategoryID=2 Or Forms!FormName!CategoryID=5)

(2) use the SetValue action with a condition:

Condition: (Forms!FormName!CategoryID = 1 Or Forms!FormName!CategoryID=2
Or Forms!FormName!CategoryID=5)
Action: SetValue
Item: Forms!FormName!CheckboxName
Expression: Yes
 
Top