=IIf([Payments Processed]>0,[Payments Time].ValidationRule=">0",[Payments
Time].ValidationRule=Null)
How can I get [Payments Time] to require it's value to be >0 if [Payments
Processed]>0 but remain 0 (it's default value) if [Payments Processed]=0?
Thanks for your help
>How can I get [Payments Time] to require it's value to be >0 if [Payments
>Processed]>0 but remain 0 (it's default value) if [Payments Processed]=0?
Use the Form's BeforeUpdate event instead. You can't control what
order the user enters the data, after all - they might fill in the
Payments Time first!
Try code like
Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me![Payments Processed] = 0 Then
Me![Payments Time] = 0
Else
If Me![Payments Time] <= 0 Then
MsgBox "Please enter a Payments Time value", vbOKOnly
Cancel = True ' prevent adding the record
Me![Payments Time].SetFocus
End If
End If
End Sub
John W. Vinson[MVP]
As this is the tables/database design group, how about a Validation
Rule in the database? Something like
(payments_processed_amount = 0 AND payments_processed_effective_date IS
NULL)
OR
(payments_processed_amount > 0 AND payments_processed_effective_date IS
NOT NULL)
Jamie.
--
>As this is the tables/database design group, how about a Validation
>Rule in the database?
Good point Jamie - though the OP crossposted to forms and formscoding
as well. It would probably be wise to do both - on the Form so you can
control the error message and make it friendlier (or more hostile if
you prefer <g>), and in the table to prevent "backdoor" entry of
invalid data.
John W. Vinson[MVP]
Svetlana, the .Text property is not used that way in the
Access object model. Use the .Value property instead.
Since Value is the default property, it is not even required
so, as John posted earlier, you could use:
If Me.[Payments Processed] = 0 Then
Me.[Payments Time] = 0
End If
--
Marsh
MVP [MS Access]