From: Jonas on
I am trying to change the required field property in for a field in an
existing table based on a value in a field in my form. I am using the
BeforeUpdate event.

Here is what I have so far:

tables!tblPayments!tblPaymentsDateWritten.Required = False

When the conditions are met, I get a message that says, "Runtime error
'424' Object Required." Can the Required property of the field be
altered from a form? If so, How can I do it?
From: Stuart McCall on
"Jonas" <sundet(a)yahoo.com> wrote in message
news:68bdf43b-85b9-4ad0-8a38-faee98d6dabf(a)d2g2000yqa.googlegroups.com...
>I am trying to change the required field property in for a field in an
> existing table based on a value in a field in my form. I am using the
> BeforeUpdate event.
>
> Here is what I have so far:
>
> tables!tblPayments!tblPaymentsDateWritten.Required = False
>
> When the conditions are met, I get a message that says, "Runtime error
> '424' Object Required." Can the Required property of the field be
> altered from a form? If so, How can I do it?

CurrentDb.TableDefs!tblPayments!tblPaymentsDateWritten.Required = False

ought to do it.


From: John W. Vinson on
On Sat, 13 Mar 2010 11:15:42 -0800 (PST), Jonas <sundet(a)yahoo.com> wrote:

>I am trying to change the required field property in for a field in an
>existing table based on a value in a field in my form. I am using the
>BeforeUpdate event.
>
>Here is what I have so far:
>
>tables!tblPayments!tblPaymentsDateWritten.Required = False
>
>When the conditions are met, I get a message that says, "Runtime error
>'424' Object Required." Can the Required property of the field be
>altered from a form? If so, How can I do it?

This is pretty clearly the wrong way to go about it!

The Required property of a field in the table applies to *EVERY SINGLE RECORD*
in the table: the field is either required to be present in all records... or
not. This property cannot be dependent on some other value, and cannot be set
dynamically from a form (especially not in a split database, which you should
be using).

I suspect you want to check the *data* in the form controls, in the Form's
BeforeUpdate event, and detect at that point whether the field is needed or
not.
--

John W. Vinson [MVP]