record count mismatch

R

ravindar thati

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" ")
rs.getRows
msgbox(rs.RecordCount)

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?
but if i put rs.getRows command multiple times, the record count is
increasing by one.
actually we have to get all the rows with single rs.getRows command .
but why this peculiar thing?
whats wrong in my code?
Thank you
 
W

Wolfgang Kais

Hello Ravindar.

ravindar said:
Hello friends,

I have a table named "Technology", two of the columns are
1. Name
2. Type
I have written a query and exectued. My code goes like this:
------------------
Dim db as Database
Dim rs as RecordSet
Set db = CurrentDb
Set rs = db.OpenRecordset("select * from Technology where" & _ " Technology.Type='Water'")
rs.GetRows
MsgBox rs.RecordCount

The recordset was not filled, because you did not yet retrieve all
records.
Try this before using the GetRows method:
if not rs.eof
rs.movelast
rs.movefirst
end if

Get rows returns an array, that you don't mention in your code...
 
R

ravindar thati

The recordset was not filled, because you did not yet retrieve all
records.
Try this before using the GetRows method:
if not rs.eof
rs.movelast
rs.movefirst
end if

Get rows returns an array, that you don't mention in your code...

thank you friend, it worked perfectly
 
G

Guest

One other thing you need to know. Name and Type are both Access reserved
words and should not be used as names of objects. Access can become confused
and return incorrect results.
 
R

ravindar thati

Try this before using the GetRows method:
if not rs.eof
rs.movelast
rs.movefirst
end if

Get rows returns an array, that you don't mention in your code...






Thank you friend.
it worked perfectly.
many thanks
 
R

ravindar thati

yes they are reserved words,
only to get my doubt clarified, i used those columns names.

Thank you friend
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top