Set Field Property using a Macro

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!
 
S

Steve Schapel

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
 

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