Results 1 to 2 of 2
Thread: Foorbid new record (Access 2000)
2005-05-29, 15:59 #1
- Join Date
- Feb 2002
- Thanked 0 Times in 0 Posts
Foorbid new record (Access 2000)
I want to avoid the possibility to enter a new record if a condition is not fulfilled.
In order to explain my condition i need to explain what i am doing.
I have a database to issue invoices.The user must fill in in the subofrom one of the
two fields: either the field cartons, or the field quantity.
If the field "cartons" is filled in by the user, then the field "quantity" is automaticall calculated
and then the form opens for a new record,for another product.
if the field "quantity" is flled by the user, then the form opens for a new record.
My database works very successfully. however there is a possibility for errors.It happens, when
for one or another reason, neither the field quantity nor the field cartons is filled in.
In that case the product in the invoice will be blank and we will have an error. This happens often
Also,the user might select a product, does not write anything for the cartons or quantity and opens the next line for another record.This again gives an error.
I want to make impossible go to a new line when :
1.both cartons and quantity are null
2. when quantity is Null
I have attached a very abridged form for my database.In order to save space i have simplified greatly
and it may give some errors, but it gives also an idea fo my problems.
I will be grateful for any help in this respect.
2005-05-29, 17:01 #2
- Join Date
- Jun 2001
- Crystal Beach, FL, Florida, USA
- Thanked 37 Times in 36 Posts
Re: Foorbid new record (Access 2000)
All you need is a few of lines of code in you form's BeforeUpdate event. You really need nothing more than this:
If isnull(me.quantity) then
msgbox "You must enter a quantity!",vbcritical
Cancel = True