Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 February 7th, 2006, 05:47 AM
Authorized User
 
Join Date: Feb 2006
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default Number of table rows to a variable

Hi ,
I need to get a number of rows in specific table to variable of type integer .
when i do the following :
Dim i As Integer
i = DoCmd.RunSql("select count(*) from myTable")

This throws me Exception . I know that this is not the smartest way to do this , but i just don't know other methods to accomplish the task .


 
Old February 7th, 2006, 08:52 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

Try

i = DCount("[PrimaryKeyField]", "myTable")

Where you replace PrimaryKeyField and myTable with their actual names.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 7th, 2006, 09:33 AM
Authorized User
 
Join Date: Feb 2006
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks , It worked!






Similar Threads
Thread Thread Starter Forum Replies Last Post
disoplaying number of rows. ashokparchuri ADO.NET 2 April 21st, 2005 04:28 AM
total number of rows in a recordset lian_a Classic ASP Basics 2 February 8th, 2005 08:13 AM
count the number of rows in the table crmpicco Javascript How-To 4 February 2nd, 2005 12:58 AM
Autofill in unknown number of rows ashu_gupta75 Excel VBA 2 August 9th, 2004 06:09 AM





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