p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Re: Recordcount of Sub-Form


Message #1 by "Haslett, Andrew" <andrew.haslett@i...> on Wed, 26 Jun 2002 11:37:57 +0930
Hi All, 

Just revisting this.  I have an unbound control in the sub-form set to
"Count(*)" which passes the value to a control on the main form.

However, if there are no records in the subform, I receive #error in that
control.

Is there a way around this? I've tried IsError(), IsErr() but to no avail.

Cheers,
Andrew

-----Original Message-----
From: Haslett, Andrew [mailto:andrew.haslett@i...]
Sent: Thursday, 18 April 2002 9:03 AM
To: Access
Subject: [access] Re: Recordcount of Sub-Form


Thanks all! Much appreciated.

A

-----Original Message-----
From: Gregory Serrano [mailto:SerranoG@m...]
Sent: Thursday, 18 April 2002 7:38 AM
To: Access
Subject: [access] Re: Recordcount of Sub-Form


<< Me.txtSubRecCount = Dcount("[any field in the subform's underlying _
   table that is always populated]", "{name of subform}", "[{field in _
   subform you want to match}] = '" & Me.[{field in main form you want _
   it to match to}] & "'") >>

Correction:

   Me.txtSubRecCount = Dcount("[any field in the subform's underlying _
   table that is always populated]", "{name of subform's underlying _
   table}", "[{field in subform you want to match}] = '" & Me.[{field _
   in main form you want it to match to}] & "'")

Greg

Message #2 by "Amy Wyatt" <amyw@c...> on Wed, 26 Jun 2002 13:21:18
Try binding the control to a function that does the following:

Function GetCount()
     Dim intCount as Integer

     If Me.CurrentRecord=0 Then   'Means there are no records
         intCount=0
     Else
         intCount=Me.RecordSetClone.RecordCount
     End If
     
     Forms!MainForm!ControlName=intCount

End Function

This should avoid the #Error displaying when no records are found.

Hope this helps,

Amy
     
> Hi All, 

Just revisting this.  I have an unbound control in the sub-form set to
"Count(*)" which passes the value to a control on the main form.

However, if there are no records in the subform, I receive #error in that
control.

Is there a way around this? I've tried IsError(), IsErr() but to no avail.

Cheers,
Andrew

-----Original Message-----
From: Haslett, Andrew [mailto:andrew.haslett@i...]
Sent: Thursday, 18 April 2002 9:03 AM
To: Access
Subject: [access] Re: Recordcount of Sub-Form


Thanks all! Much appreciated.

A

-----Original Message-----
From: Gregory Serrano [mailto:SerranoG@m...]
Sent: Thursday, 18 April 2002 7:38 AM
To: Access
Subject: [access] Re: Recordcount of Sub-Form


<< Me.txtSubRecCount = Dcount("[any field in the subform's underlying _
   table that is always populated]", "{name of subform}", "[{field in _
   subform you want to match}] = '" & Me.[{field in main form you want _
   it to match to}] & "'") >>

Correction:

   Me.txtSubRecCount = Dcount("[any field in the subform's underlying _
   table that is always populated]", "{name of subform's underlying _
   table}", "[{field in subform you want to match}] = '" & Me.[{field _
   in main form you want it to match to}] & "'")

Greg


  Return to Index