form-subform error trapping?

G

Guest

I have a form with a subform embedded. (Invoice general data - invoice
concepts data)
They are linked in a relation one-to-many by an integer field that must be
captured by the user (invoiceID)
When the user tryes to insert new records in the subform, and the invoiceID
is missing an error occurs

I want to trap the error positioning the cursor in the invoiceID field and
sending the message that the field is required.

I have tried with
myForm_beforeUpdate
mySubForm_beforeUpdate
to check if the invoiceID is missing but it doesn't work: the error is not
trapped

is it suitable to use
myForm_error
mySubForm_error
?

thanks in advance
 
M

Marshall Barton

robeito said:
I have a form with a subform embedded. (Invoice general data - invoice
concepts data)
They are linked in a relation one-to-many by an integer field that must be
captured by the user (invoiceID)
When the user tryes to insert new records in the subform, and the invoiceID
is missing an error occurs

I want to trap the error positioning the cursor in the invoiceID field and
sending the message that the field is required.

I have tried with
myForm_beforeUpdate
mySubForm_beforeUpdate
to check if the invoiceID is missing but it doesn't work: the error is not
trapped

is it suitable to use
myForm_error
mySubForm_error
?


Generally, you should use the subform's BeforeUpdate event
to do data validation:

Sub Form_BeforeUpdate( . . .
If IsNull(invoiceID) Then
Beep
Cancel = True
End If
End Sub

BUT, wouldn't the invoiceID field be filled in automatically
if you used it in the LinkMaster/Child properties? Or is
there more to your situation??
 
G

Guest

Invoices table definition: InvoiceID must not be null (primary key)
Concepts table definition: InvoiceID must not be null (part of the primary
key)

Error shown: InvoiceID must not be null (I'm using Access 2002 in spanish)

This error appears first and the error trapping code is not triggered
 
M

Marshall Barton

robeito said:
The user forgets to capture the invoice ID: I want to trap this situation


As I said, you can use the form's BeforeUpdate event to
check if the user forgot to enter the InvoiceID.

It still looks like you can use the LinkMaster/Child
properties to automatically get the main form's InvoiceID
placed into the subform's InvoiceID field without the user
needing to do anything at all.
 

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