Sum datasheet subform field on main form
Posted on 2007-03-21
I have a form which has a datasheet subform showing detail lines (think along the lines of an invoice header/detail form).
I wanted to have a subform field summed on the mainform. I accomplished this by putting a Sum() textbox in the subforms footer and referencing it by it's name (it works great!) in a textbox on the mainform.
Here's the problem; if there is no records in the subform, it returns "#Error" as the value of my summed textbox on the main form. I go into debug and find the textbox gives an "Run-time error '9': Subscript out of range". I believe that this is happening because the subform footer does not exist, so I am referencing a non-existent textbox.
Here my question , can I trap this error and force it to be zero if this error happens OR can I go about this in an easier way?
Thanks in advance.