Stopping new record creation

D

Dan

I have an Order entry form that contains fields for customer name and order
date. It also contains a subform with order details.

I would like to test the customer name and order date and in certain
situations stop it from generating a new record. But it seems like whenever I
tab past one of the order header fields, it automatically generates a new
record. Is there an event handler or method that I can use to do my test and
keep the new record from being generated (rather than letting it be generated
and then deleting it)?

I'm using Access 2007.

Thanks!
 
J

Jim Burke in Novi

I think you just want to change the setting of the Form's Cycle property from
All Records, which is the default, to Current Record.
 
K

Klatuu

Use the form's Before Update event. You can test for missing or incorrect
data and if found can cancel the update:

Form_BeforeUpdate(Cancel As Integer)

If IsNull(DLookup("[CustID]", "tblCustomer","[CustName] = " &
Me.txtCustName)) Then
MsgBox "Customer Not Found"
Cancel = True
End If

If IsNull(Me.txtOrderDate) Then
MsgBox "Order Date Requored"
Cancel = True
End If
End Sub

If the customer is not in the database or no order date has been entered,
the record will not be added to the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top