forms and recordcount

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do i determine the number of records in the underlying table/query in an
open form and then force a particular field to be either visible (or not) if
the number of records is > 1
i am using the 'on current event' property to set this.

if have tried combination of below without success:
' Me.[Combo7].Visible = (.RecordsetClone.RecordCount > 1)
'Me![Combo7].Visible = (.record.RecordCount > 1)
'With Me![Combo7]
'.Visible = (rsa.RecordCount > 1)
' End With
--


Regards


Patrick Stubbin
 
The easiest way is probably:

Me.[Combo7].Visible = (DCount("*", Me.RecordSource) > 1)

Note: If you do want/need to use RecordsetClone, the RecordCount won't be
accurate until you moved to the last record.

HTH,

Rob
 
Patrick said:
How do i determine the number of records in the underlying table/query in an
open form and then force a particular field to be either visible (or not) if
the number of records is > 1
i am using the 'on current event' property to set this.

if have tried combination of below without success:
' Me.[Combo7].Visible = (.RecordsetClone.RecordCount > 1)
'Me![Combo7].Visible = (.record.RecordCount > 1)
'With Me![Combo7]
'.Visible = (rsa.RecordCount > 1)
' End With


Rather than the Current event, which executes as you
navigate from record to record. Try using the Load event
and right after any Requery statements you may have.

With Me.RecordsetClone
.MoveLast
Me.[Combo7].Visible = (.RecordCount > 1)
End With

The MoveLast is critical since the RecordCount property only
tells you how many records have actually been accessed so
far, frequently just 1. The MoveLast accesses all the
records, so RecordCount will reflect all the records in the
form's record source.
 
thankyou
--
Regards


Patrick Stubbin


Marshall Barton said:
Patrick said:
How do i determine the number of records in the underlying table/query in an
open form and then force a particular field to be either visible (or not) if
the number of records is > 1
i am using the 'on current event' property to set this.

if have tried combination of below without success:
' Me.[Combo7].Visible = (.RecordsetClone.RecordCount > 1)
'Me![Combo7].Visible = (.record.RecordCount > 1)
'With Me![Combo7]
'.Visible = (rsa.RecordCount > 1)
' End With


Rather than the Current event, which executes as you
navigate from record to record. Try using the Load event
and right after any Requery statements you may have.

With Me.RecordsetClone
.MoveLast
Me.[Combo7].Visible = (.RecordCount > 1)
End With

The MoveLast is critical since the RecordCount property only
tells you how many records have actually been accessed so
far, frequently just 1. The MoveLast accesses all the
records, so RecordCount will reflect all the records in the
form's record source.
 
thankyou
--
Regards


Patrick Stubbin


Rob Parker said:
The easiest way is probably:

Me.[Combo7].Visible = (DCount("*", Me.RecordSource) > 1)

Note: If you do want/need to use RecordsetClone, the RecordCount won't be
accurate until you moved to the last record.

HTH,

Rob

Patrick Stubbin said:
How do i determine the number of records in the underlying table/query in an
open form and then force a particular field to be either visible (or not) if
the number of records is > 1
i am using the 'on current event' property to set this.

if have tried combination of below without success:
' Me.[Combo7].Visible = (.RecordsetClone.RecordCount > 1)
'Me![Combo7].Visible = (.record.RecordCount > 1)
'With Me![Combo7]
'.Visible = (rsa.RecordCount > 1)
' End With
--


Regards


Patrick Stubbin
 
Back
Top