473,395 Members | 1,456 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,395 software developers and data experts.

rs.RecordCount linked to a sql server db

6
I have some code in an ONCURRENT event that is running a query and then counting the number of records returned. However the RecordCount is always returning 1. I know the query works .. i put a msgbox and capture the query its running and when i run it in a query it returns the all the records.

The interface is in access but it is linked to a SQLServer database...

Dim db As Database
Dim rs, rs2 As Recordset
Dim strSql As String
Dim orgCount, nomCount, estimate As Integer

'Initialize to return Null on error.
Set db = CurrentDb

strSql = "SELECT qryCeremonyProgram.organizationName FROM qryCeremonyProgram where qryCeremonyProgram.ceremonyId = " & Parent.ceremonyid & " GROUP BY qryCeremonyProgram.organizationName"

Set rs = db.OpenRecordset(strSql)

orgCount = rs.RecordCount 'Return the number of distinct records.
MsgBox (orgCount)
Nov 22 '07 #1
2 2250
smook
6
Oh ... well I solved it myself. I guess you have to move through the recordset first so adding:

rs.moveLast

before the rs.RecordCount seemed to clear that up.
Nov 22 '07 #2
ADezii
8,834 Expert 8TB
Oh ... well I solved it myself. I guess you have to move through the recordset first so adding:

rs.moveLast

before the rs.RecordCount seemed to clear that up.
You hit the nail on the head, some Recordsets you must explicitly traverse in order to get an accurate RecordCount, some Recordsets return the number of Records actually accessed (1), which seems to be your case. Whenever I need an accurate RecordCount, I always include the following line in my code:
Expand|Select|Wrap|Line Numbers
  1. rs.MoveLast:rs.MoveFirst
Nov 22 '07 #3

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

Similar topics

3
by: David Gray | last post by:
Hello all, Having problems connecting to an Oracle 9i database from within SQL/Server 2000 using the Security/Linked Servers feature. Server1 (SQL/Server) ----------- Windows Server 2003,...
4
by: pheonix1t | last post by:
hello, I'm trying to create a linked server from an SQL2000 to a Unify ELS (very old, odbc is version 1) database on SCO unix. The odbc driver is old but it works fine when used by applications...
1
by: TBlair | last post by:
I am about to start working on a project where I would be required to dynamically create linked servers during the execution of an application. One of the requirements is for the Link Servers to be...
4
by: arichie | last post by:
Can anyone point me where can I find a good architectural document on how the Linked server works in SQL Server. I am not asking about how to use Linked server, I am interested in know how it is...
8
by: Crazy Cat | last post by:
Hi, When I click on the properties of a linked server, all the General properties are read - only, which means that if I want to edit any general properties I have to delete the linked server...
1
by: tim.pascoe | last post by:
I've been trying to work with Linked Servers for the first time, with mixed success. My problem right now is in trying to write a View using a linked server. The linked server is another...
2
by: Larry Bertolini | last post by:
Is there a way to read data from a linked server, within a transaction, without using DTC? The data on the linked server is static, therefore there is no need for two-phase commit. There is no...
6
by: Neil | last post by:
After creating a linked server to a remote server, I needed to log in using sp_addlinkedsrvlogin to get my stored procedure to work. However, I noticed that after stopping SQL Server and the DTC...
5
by: Neil | last post by:
I am getting time-out errors when I try to perform a simple delete on a linked server. The command is: Delete From MyTable Where PKID=12345 I have tried executing this command directly from...
1
by: BillCo | last post by:
There seems to be a lot of confusion around the groups about linking to an Access mdb with the SQL Server Jet OLE DB provider and I havent been able to find a straight forward solution. Basically,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.