Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2005, 05:55 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count of form records

I apologise if this is simple, but it has been bugging me for weeks. I have a template form which is populated by inserting an SQL string into its RecordSource property. The users have asked if I can display the number of records that are displayed on the form in a Text box in the form footer. For some reason they do not want the Navigation boxes to be displayed which is by far the simplest solution. On the occasions when the source is a table it is simple using Dcount, but when the source is a query string I have tried all I can think of to populate the TextBox using the form's OnOpen event (Me.Text1.value = Me.RecordSource.Recordcount etc) but cannot find a way to do it. Does anyone know a way to do this?

Thanks

Spikey

 
Old April 20th, 2005, 07:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Have you tried using a combination DCOUNT with Me.RecordSource? That is

Me.Text1 = DCount("[Pick a field]", Me.RecordSource)


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old April 20th, 2005, 09:01 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wonderful! It was probably the only combination of DCount and me.RecordSource I hadn't tried.

Many, many thnks.



 
Old April 20th, 2005, 09:09 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

PMJIH.

There's one thing you should know about the field Greg specified as "[Pick a field]". If you pick a field that could be Null, the record won't be counted. Recommend using either "*" or the ID field (a field which should never be null) of the record source.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Variables to Count Unique Records Dallas Miller BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 October 18th, 2007 08:03 AM
Pls Help me count records [soon after connection] amjad_mahmood VB Databases Basics 1 August 30th, 2005 07:20 PM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
Listing records based on a count harg7769 Access 3 April 8th, 2005 03:15 AM
count records where condition not true (IIF??) rpeksens Access 3 September 19th, 2003 03:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.