473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

record count mismatch

hello friends,

i have a table named "Technology"
it has few columns.
of them two are
1.Name
2. Type



i have written a query and exectued like this
my code goes like this

dim db as database
dim rs as Recordcount
set db=CurrentDb
set rs=db.OpenRecordset("select * from Technology where Technology.Type="Water" ")

if i execute this query in query wizard i get record count correctly.
but when i implement this query in my code, it displays record count as 2 every time.

same query , but why i am facing the problem?


Thank you
Oct 25 '07 #1
2 3828
FishVal
2,653 Expert 2GB
hello friends,

i have a table named "Technology"
it has few columns.
of them two are
1.Name
2. Type



i have written a query and exectued like this
my code goes like this

dim db as database
dim rs as Recordcount
set db=CurrentDb
set rs=db.OpenRecordset("select * from Technology where Technology.Type="Water" ")

if i execute this query in query wizard i get record count correctly.
but when i implement this query in my code, it displays record count as 2 every time.

same query , but why i am facing the problem?


Thank you
Hi, there.

What does the Recordcount type / classname mean? Did you mean DAO.Recordset?

Anyway Recordset opening is asynchronous to VBA code executing. Recordset.RecordCount property doesn't return right value immediately after Recordset was opened. To force Recordset object to determine number of records use Recordset.MoveLast method.

e.g.

Expand|Select|Wrap|Line Numbers
  1. dim db as database
  2. dim rs as DAO.Recordset
  3. set db=CurrentDb
  4. set rs=db.OpenRecordset("select * from Technology where Technology.Type='Water';")
  5. rs.MoveLast
  6. Debug.Print rs.RecordCount
  7.  
Oct 25 '07 #2
ADezii
8,834 Expert 8TB
Hi, there.

What does the Recordcount type / classname mean? Did you mean DAO.Recordset?

Anyway Recordset opening is asynchronous to VBA code executing. Recordset.RecordCount property doesn't return right value immediately after Recordset was opened. To force Recordset object to determine number of records use Recordset.MoveLast method.

e.g.

Expand|Select|Wrap|Line Numbers
  1. dim db as database
  2. dim rs as DAO.Recordset
  3. set db=CurrentDb
  4. set rs=db.OpenRecordset("select * from Technology where Technology.Type='Water';")
  5. rs.MoveLast
  6. Debug.Print rs.RecordCount
  7.  
As indicated by FishVal, many times it is a good idea, if practical, to 'traverse' the Recordset for an accurate RecordCount. What I usually do is:
Expand|Select|Wrap|Line Numbers
  1. 'RecordCount will always be valid with this Method
  2. rs.MoveLast:rs.MoveFirst
Oct 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
2
by: Alicia | last post by:
Hi, I have a simple question. I wanted to count a Column containing Dates and the word "Empty". This is what I am trying to do. Closed Dates ------------ 4/2/2004 4/7/2004 4/9/2004
1
by: Scott269 | last post by:
So I've got an old MS Works database I imported into Access. I needed a primary key so I created a record number field that was just the record number I manually inserted when I entered it in the...
1
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the...
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
2
by: andrewbb | last post by:
This is fairly simple code, what am I missing or is there a potential workaround? It fails when passing someParms to Invoke with "Parameter count mismatch". I created a test with an empty form...
2
by: glynester | last post by:
I have some code that works off the update event of a textbox field (which is a part of a record in a continuous form). If certain conditions are met (following the updating of the field), I want a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.