Set Field Property using a Macro

  • Thread starter Thread starter Jennifer
  • Start date Start date
J

Jennifer

I need to set a fields required property to true if
another fields value is true, else I need the fields
required property to remain false. Does anyone know how
to do this?

Thanks in advance!
 
Jennifer,

It is not possible to do this with a macro. Even if it was possible,
it wouldn't work... a property setting like this refers to all
records.

One approach would be to use the Before Update event of your form(s)
to check the field values. To do this with a macro, you would put the
equivalent of this as the macro Condition...
[FirstField]=-1 And [SecondField] Is Null
.... with perhaps two actions in the macro:
CancelEvent
MsgBox

Another approach is to set a Table-level Validation Rule. In the
design view of the table, select Properties from the View menu, and
then enter Validation Rule such as...
[FirstField]=0 Or ([FirstField]=-1 And [SecondField] Is Not Null)
.... and with an appropriate entry in the Validation Text property as
well.

- Steve Schapel, Microsoft Access MVP
 
Back
Top