Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 November 11th, 2004, 04:13 AM
Authorized User
 
Join Date: Nov 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default recordset

Hi friends,

Why is it that, I want to total records in my database. So I used the code like:

Text6.tert = rsproduct.recordcount

The result is -1?

Do you have code if you can?

rudner


 
Old November 11th, 2004, 05:18 PM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this code

Dim rec as Recordset
Dim db as Database

Set db = Currentdb() ' set a reference to the current database

Set rec = db.OpenRecordset("table_name", dbOpenDynaset) ' this opens the table
      rec.MoveFirst ' Move to the first record in table
      Text6.Value = rec.Recordcount
      rec.Close ' closes the connection to the table

'release the objects
rec = Nothing
db = Nothing

Hope this helps!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset Tantan VB How-To 1 May 31st, 2007 12:04 AM
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Query from Recordset into another Recordset kamrans74 Pro VB Databases 5 March 5th, 2007 04:17 PM
ADODB.Recordset (0x800A0CB3)Current Recordset does tks_muthu Classic ASP Databases 0 June 16th, 2005 07:22 AM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM





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