Error 2427

A

arm

Hello! Could anyone please help me. I have this subform that has a control
called "txtTotalDesignMhrs" with a control source "=Sum([Design Mhrs])". In
one of the Main form control AfterUpdate event the value of this subform
control (txtTotalDesignMhrs) is assigned to a variable called
"dblTotalDesignMhrs" (see code below:

dblTotalDesignMhrs = me.parent!fsubMySubform.form!txtTotalDesignMhrs

The problem there is this error message that pops up "ERROR 2427 : YOU
ENTERED AN EXPRESSION THAT HAS NO VALUE" and it only shows up whenever there
is no record displayed in the subform. How can I get around this problem?

Thank you very much in advance for the help.
 
A

Allen Browne

If there are no records for a form, and no new records can be added, the
detail section goes completely blank. Then attempting to refer to the
(non-existent) text box [Design Mhrs] causes an error, so the
txtTotalDesignMhrs which makes that reference will contain an error.

You could test for the Error condition, or you could avoid the error like
this:
With me.parent!fsubMySubform.form
If .RecordsetClone.RecordCount > 0 Then
dblTotalDesignMhrs = Nz(!txtTotalDesignMhrs,0)
End If
End With

While that is what is going on in your case, I have oversimplied the
explanation. There is also a design flaw in Access that causes it to mess up
the references in the Form Header and Form Footer sections, even if they
don't refer to a non-existent control in the detail section. More info in:
Incorrect display of data
at:
http://members.iinet.net.au/~allenbrowne/bug-06.html
 

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