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 May 1st, 2007, 09:55 PM
Authorized User
 
Join Date: Mar 2007
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help With Count Function

Hi all,

I need some help with i think it to be the Count function. I have a list box on a form which displays a list of files, i require a box on the form that display the count of the records in the list box. I have tried setting an expression =Count([List2]) but #Error is the result. If someone could advise of the correct code that would of great help.

Thanks
Darren

 
Old May 2nd, 2007, 09:38 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are these files kept in a table or just in the list box? You may be able to use the DCount function.

 
Old May 2nd, 2007, 09:46 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default


The ListCount Property may be the way to go. Here is a snippet of code using it.
Code:
    Dim ListControl As Control

    Set ListControl = Forms!Customers!CustomerList
    With ListControl
        If .ListCount < 8 Then
            .ListRows = .ListCount
        Else
            .ListRows = 8
        End If
    End With


I think you can also set it up something like:
intVariable = Me.lstName.ListCount

 
Old May 2nd, 2007, 06:52 PM
Authorized User
 
Join Date: Mar 2007
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Stealth

Great name!!

Thanks for your help, yes the data is only stored in the list box, i tried your suggestion (listcount) and i am now getting a count value.

Thanks for help!!

Cheers






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Count() function 4 group of records Odeh Naber Access 0 July 24th, 2007 03:28 AM
Running Count Function jdbash1 Access VBA 1 June 7th, 2007 11:03 AM
Count Function returns strange value tslag XSLT 2 June 23rd, 2006 10:13 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Count aggregate function Robert_Hill BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 August 24th, 2004 01:12 PM





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