Not understanding the hasdata function

R

Rotata

Access 2003 on XP, all updates

I have a form with a subform.

The main form shows the crew information, such as name of crew, location of
office, and areas of control.
The subform shows all employees on that crew and counts records.
The main form displays the count of those employees.
If the crew has 10 employees, the form displays 10.
If a crew has no employees, then the main form shows #error.

this is the code in an unbound text box on the main form:
=frmEmployeeInfoFTE.Form!Text15

this is the code in the unbound text box on the subform:
=Sum([sum of fte])

I must be stupid, because I do not understand the directions on how to make
the main form display 0 when no records are present.

Thanks!
 
R

Rotata

Using those directions, I put

=IIf(Form.Recordset.RecordCount>0,Sum([Sum Of fte]),0)

in the subform sum field.

I left
=frmEmployeeInfoFTE.Form!Text15
in the main form field.

Still getting the error message.

What am I doing wrong?

Thanks,


--
Computer Lover


Jeanette Cunningham said:
Hi Rotata,
this page called Avoid #Error in form/report with no records on

http://allenbrowne.com/RecordCountError.html

shows how to do it.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Rotata said:
Access 2003 on XP, all updates

I have a form with a subform.

The main form shows the crew information, such as name of crew, location
of
office, and areas of control.
The subform shows all employees on that crew and counts records.
The main form displays the count of those employees.
If the crew has 10 employees, the form displays 10.
If a crew has no employees, then the main form shows #error.

this is the code in an unbound text box on the main form:
=frmEmployeeInfoFTE.Form!Text15

this is the code in the unbound text box on the subform:
=Sum([sum of fte])

I must be stupid, because I do not understand the directions on how to
make
the main form display 0 when no records are present.

Thanks!
 
J

Jeanette Cunningham

Rotata,
You still need to tweak your code to fully follow the instructions.
Here is the relevant instruction from the function in that code.

'Usage: in the Control Source of the text box:
' =IIf(FormHasData([Form]), Sum([Amount]), 0)
' 'To handle unbound forms use On Error Resume Next
'Leave the [Form] part of the expression as it is (i.e. do not substitute
the name of your form.)

So your expression should be
=IIf(FormHasData([Form]), Sum([Sum Of fte]), 0)

Try that.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Rotata said:
Using those directions, I put

=IIf(Form.Recordset.RecordCount>0,Sum([Sum Of fte]),0)

in the subform sum field.

I left
=frmEmployeeInfoFTE.Form!Text15
in the main form field.

Still getting the error message.

What am I doing wrong?

Thanks,


--
Computer Lover


Jeanette Cunningham said:
Hi Rotata,
this page called Avoid #Error in form/report with no records on

http://allenbrowne.com/RecordCountError.html

shows how to do it.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Rotata said:
Access 2003 on XP, all updates

I have a form with a subform.

The main form shows the crew information, such as name of crew,
location
of
office, and areas of control.
The subform shows all employees on that crew and counts records.
The main form displays the count of those employees.
If the crew has 10 employees, the form displays 10.
If a crew has no employees, then the main form shows #error.

this is the code in an unbound text box on the main form:
=frmEmployeeInfoFTE.Form!Text15

this is the code in the unbound text box on the subform:
=Sum([sum of fte])

I must be stupid, because I do not understand the directions on how to
make
the main form display 0 when no records are present.

Thanks!
 

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