count(*) in subform footer returning #error in mainform when no records in subform (1 Viewer)

Happy YN

Registered User.
Local time
Today, 01:34
Joined
Jan 27, 2002
Messages
425
My count(*) in subform(called "subsearch") footer works fine and is blank when no records are on the form.
My mainform has a textbox which references the subforms textbox (correctly!) This works fine BUT when the subform is empty (no records), returns an #error.
I have tried iif([SubSearch].[Form]![txtSubformCount]>0,[SubSearch].[Form]![txtSubformCount],null) in the control source to no avail.
I also tried =iif([SubSearch].[Form]![txtSubformCount]=null,null,[SubSearch].[Form]![txtSubformCount])
I have also tried using nz
I just can't get the mainform textbox to display 0 or at least remain blank when the subform contains no records even though the count(*) remains blank on the subform footer
Any ideas?
Thanks
 
Last edited:
R

Rich

Guest
=Iif(IsNumeric([SubSearch]![txtSubformCount]),[SubSearch]![txtSubformCount],0)
 

Happy YN

Registered User.
Local time
Today, 01:34
Joined
Jan 27, 2002
Messages
425
Thanks Rich
Yes I was looking for a function like isnumeric but didn't know it existed!
However for some reason I put the question in the vba section even though I had intended to put it in the forms section
I would like to put this expression into the control source property of the mainform textbox without having to code it in vba but the controlsource property does not want to accept it. Does access recognise isnumeric or is there another equivalent?
Thanks again
PS
Have tried it in vb but I can't get the mainform txtbox to reflect the count of the subform because it seems to take a moment before executing the count(*) and by then the mainform txtbox has set itself to null???
Thanks
 
Last edited:

Happy YN

Registered User.
Local time
Today, 01:34
Joined
Jan 27, 2002
Messages
425
Please ignore previous post
its working fine now using isnumeric in the controlsource property for the txtbox
I guess i did not put the syntax correctly before!
Thanks again
 

Oldsoftboss

AWF VIP
Local time
Today, 10:34
Joined
Oct 28, 2001
Messages
2,499
Rich

My form displays the #error in a txtbox also.
It is an account balance from a subform txtbox that sums the totals of a field.

Noticed that when the subform has the Allow Additions set to yes, the main form displays a zero, but when set to no, displays the #Error msg.

As this form is used for view a summary of transactions and not adding or altering I would like the additions set to no.

Tried the IsNumeric but it seems to lock up the Db. Is there another IIf to use ?

Have tried IsNull and Nz without success.
Dave
 
Last edited:

Users who are viewing this thread

Top Bottom