If query has no results

crxftw

Registered User.
Local time
Today, 23:27
Joined
Jun 9, 2011
Messages
81
Hello. In my main form I am using 3 sub-forms, from where I get totals to calculate Total Payment. But if one of the subform queries has 0 results from the query, then my Total field gives me #Error!, because this field doesn't exist. In subform I have put the total field to its header.

Is it possible to make the subform field to display me '0' in case no results are returned, or make the Total field ignore the missing field? I have tried to find solutions to this all over but haven't found any. Simple Nz or IIf are not doing the job for this one.

Thanks!
 
Hmm this way I could eliminate my #error problem in main form, but I would need to display in my db for example: If it's new tax year, first payslip of the month, then an employee has entitled 0 hours of Holiday Pay, same query also returns me total salary worked til date, so if there is no entitled hours and no total salary for first month, query returns nothing to me and both fields in subform are empty. In there salary field is hidden, but Total entitled (available) hours field is visible, and I would need it to display me 0.

Hope it makes sense.
 
If I understand correctly, this could be an alternative to..:


Code:
private sub form_current()

textbox_name=iif(me.subform_name.form.recordsetclone.recordcount=0, _
         0,subform_name.form.txtbox_sum)

end sub
 

Users who are viewing this thread

Back
Top Bottom