Changing the properties of a control

J

Justin83716

Quick question. I have a form with a control who's underlying table field has
it's "required" property set to yes. I also have a check box on the form that
I would like to use to change the controls required property to NO. Is the
only way to do this with code? If so I can only figure out the first half of
the code.

Private Sub chkActuals_Click()
If Me.chkActuals = True Then
'change cboWeeklyAllowance to Not required
End Sub

Thanks for any help!
 
B

Bill Edwards

As long as the field has been defined as required in the table, this cannot
be over-ridden at the form level.
The only option would be to changed Required = Yes to Required = No at the
table level and then put code in your form to check to see if the field has
or has not been provided.
 
J

Justin83716

That's what I needed to know, thanks!

Bill Edwards said:
As long as the field has been defined as required in the table, this cannot
be over-ridden at the form level.
The only option would be to changed Required = Yes to Required = No at the
table level and then put code in your form to check to see if the field has
or has not been provided.
 
M

Marshall Barton

Justin83716 said:
Quick question. I have a form with a control who's underlying table field has
it's "required" property set to yes. I also have a check box on the form that
I would like to use to change the controls required property to NO. Is the
only way to do this with code? If so I can only figure out the first half of
the code.

Private Sub chkActuals_Click()
If Me.chkActuals = True Then
'change cboWeeklyAllowance to Not required
End Sub


Not a reasonable idea. The required property applies to the
entire column in the table, not to any one specific row.

OTOH, you can use the **table** Validation Rule to check for
multiple field restrictions. Try removing the field's
Required property and use a table Validation Rule something
like:
[Actuals] Or [WeeklyAllowance] Is Not Null
 
J

Justin83716

Using the table validation rule for the field instead of the required
property seems like a good option to me. Rethinking the whole required
propety idea now I realize that it would not have worked for my purposes
anyway. Thanks to all for the helpful insights!

Marshall Barton said:
Justin83716 said:
Quick question. I have a form with a control who's underlying table field has
it's "required" property set to yes. I also have a check box on the form that
I would like to use to change the controls required property to NO. Is the
only way to do this with code? If so I can only figure out the first half of
the code.

Private Sub chkActuals_Click()
If Me.chkActuals = True Then
'change cboWeeklyAllowance to Not required
End Sub


Not a reasonable idea. The required property applies to the
entire column in the table, not to any one specific row.

OTOH, you can use the **table** Validation Rule to check for
multiple field restrictions. Try removing the field's
Required property and use a table Validation Rule something
like:
[Actuals] Or [WeeklyAllowance] Is Not Null
 
Top