check form record count for records then...

what I would like to do is, check the forms record count for records if so then some else show 0

IIf (form.recordset.recordcount>0, NZ ([Forms]! [Myform]! [Myfield],0) + ([Forms]...,0)

Open in new window


Is this correct?
Ernest GroggSecurity Management InfoSecAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
The navigation bar shows the record count and doesn't require any code.
Ernest GroggSecurity Management InfoSecAuthor Commented:
Yes, what I have is subforms with totals on each.  But if there is no records for that selection the total is left blank and doesn't show zero (0) ir show's a #Errors .  So the total of each subform is totaled on the main form.  If there is zero I want the total to show a zero, not a blank or empty field.  
I also have noticed a #error on the form/report if there is no records.  If there is no records, I want to display a zero in the control.  That way the total for all subforms /reports show zero or the sum.
PatHartmanCommented:
The totals for the subform should be in the subform footer.  they will have a name like: txtsmfldA and a ControlSource something like:
=Sum(fldA)

Then the ControlSource in the main form will look something like:

=sfrm!txtsumfldA

Let us know if you are doing something else.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ernest GroggSecurity Management InfoSecAuthor Commented:
What I am trying to aviod is this:  

What seems to be happening...is if there is no records for the entry as in the attached the control remains empty and doesn't read zero (0).  I want that to read a zero if nothing is there.  That is why I asked the IIF/then/Else question.

If the recordset is Zero (0) then display a Zero (0), else if there are records then display the count.  




BlankRecordsEntry
IIf (form.recordset.recordcount>0, NZ ([Forms]! [Myform]! [Myfield],0) + ([Forms]...,0)

Open in new window

PatHartmanCommented:
=Nz(sfrm!txtsumfldA, 0)

Might solve the problem
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.