Full Version: Make sure not pay amt fields are 0 or less
UtterAccess Discussion Forums > Microsoft® Access > Access Modules
3587
I have a continuos subform with a pay amt currency field and a button on the main form that saves all entries on the sub form. I need a way to make sure the pay amt field for each record on the sub form is greater than zero when the button on the main form is clicked.


Thank you,
tunkefer
Assuming you have VB code in the button's OnClick event, you'll need something like this before the code that saves the data:

>If Me!subFormName!amountField = 0 then
> Exit Sub
>End If


TomU
3587
But there is more than one record in the sub form, will this check them all?

Thanks,
tunkefer
Oops. I just noticed that the subForm is continuous. Is just one line added at one time? If so, my earlier answer works. If not, more code is needed.


TomU
3587
Yes there could be more than one record in the sub form.

Thanks,
tunkefer
Since you're adding multiple lines to the subForm, I think the best place to detect the zero payment is in the BeforeUpdate event within the subForm. This will catch the condition in the current line before the user adds a new line.

TomU
3587
I'll give that a try.

Thank you,
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.