473,700 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Whats wrong with this code

Hello!

Can someone tell me whats wrong with this piece of code:

Option Compare Database
Option Explicit

Sub retrieve()
Dim rst As ADODB.Recordset
Dim i As Integer

Set rst = New ADODB.Recordset

rst.Source = "qryVintage r"
rst.ActiveConne ction = CurrentProject. Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimisti c
rst.Open

i = rst.RecordCount

MsgBox "Record count: " & i
End Sub

'qryVintager' is predefined query. I run it directly in Access. According to
the book I use, this should work.

Thanks in advance for your help!
Jochen
Nov 12 '05 #1
4 4061
JL
You have to explicitly move to the end of the recordset in order for Access
to know how many records it actually contains. In DAO the syntax is
something like rst.MoveLast...
"asdf" <as**@asdf.co m> wrote in message
news:3f******** *************@r ead.news.ch.uu. net...
Hello!

Can someone tell me whats wrong with this piece of code:

Option Compare Database
Option Explicit

Sub retrieve()
Dim rst As ADODB.Recordset
Dim i As Integer

Set rst = New ADODB.Recordset

rst.Source = "qryVintage r"
rst.ActiveConne ction = CurrentProject. Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimisti c
rst.Open

i = rst.RecordCount

MsgBox "Record count: " & i
End Sub

'qryVintager' is predefined query. I run it directly in Access. According to the book I use, this should work.

Thanks in advance for your help!
Jochen



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #2
"asdf" <as**@asdf.co m> wrote in message news:<3f******* **************@ read.news.ch.uu .net>...
Hello!

Can someone tell me whats wrong with this piece of code:

Option Compare Database
Option Explicit

Sub retrieve()
Dim rst As ADODB.Recordset
Dim i As Integer

Set rst = New ADODB.Recordset

rst.Source = "qryVintage r"
rst.ActiveConne ction = CurrentProject. Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimisti c
rst.Open

i = rst.RecordCount

MsgBox "Record count: " & i
End Sub

'qryVintager' is predefined query. I run it directly in Access. According to
the book I use, this should work.

Thanks in advance for your help!
Jochen


Probably D Bugger will give you a clue, perhaps with a message;
invoking his/her name one may locate the exact line where the problem
(if there is a problem) occurs. If I had to guess, I'd guess the
number of records is greater than the largest number that will fit
into two bytes (integer).
Nov 12 '05 #3
"asdf" <as**@asdf.co m> wrote in message news:<3f******* **************@ read.news.ch.uu .net>...
Hello!

Can someone tell me whats wrong with this piece of code:

Option Compare Database
Option Explicit

Sub retrieve()
Dim rst As ADODB.Recordset
Dim i As Integer

Set rst = New ADODB.Recordset

rst.Source = "qryVintage r"
rst.ActiveConne ction = CurrentProject. Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimisti c
rst.Open

i = rst.RecordCount

MsgBox "Record count: " & i
End Sub

'qryVintager' is predefined query. I run it directly in Access. According to
the book I use, this should work.

Thanks in advance for your help!
Jochen


Probably D Bugger will give you a clue, perhaps with a message;
invoking his/her name one may locate the exact line where the problem
(if there is a problem) occurs. If I had to guess, I'd guess the
number of records is greater than the largest number that will fit
into two bytes (integer).
Nov 12 '05 #4
Hi JL,

That's not entirely true of ADO (it is of DAO).

If you are using a client side cursor location you don't need perform the
MoveLast method.

Adding rs.CursorLocati on = adUseClient allows you to grab the count (and
generally gives you a richer enviroment by buffering the recordset
locally).

Also using rs.CursorType = adOpenKeyset will allow you to grab the count
with move last.

As is generally the case, the more features the larger the overhead, though
I've never seen any comparison stats myself (never looked).

Peter

"JL" <JL@JL.COM> wrote in news:3f******** **@corp.newsgro ups.com:
You have to explicitly move to the end of the recordset in order for
Access to know how many records it actually contains. In DAO the
syntax is something like rst.MoveLast...

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2390
by: Chris Geerdink | last post by:
combo with PHP. what is wrong with the Javascript? else { include("mysql.php"); $query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES ('".$_POST."', '".$_POST."', '".$_POST."')"); ?> <script language="JavaScript"> <!--
1
2460
by: aa | last post by:
When I am reading from local disk (d:), everithing is OK, but then I am reading from map disk I am geting the this error. Whats wrong. Thanks Server Error in '/Extra' Application. ---------------------------------------------------------------------------- ---- The specified user does not exist. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more...
3
2039
by: mahsa | last post by:
Hi do you know whats wrong with this code? <asp:HyperLink id="HLink_Help" runat="server" NavigateUrl='<%# "javascript:window.open('comments.aspx?id=1,width=500,height=600, scrollBars=yes');" %>'>Need Help?</asp:HyperLink> -- mahsa
4
3539
by: blah | last post by:
Hello everyone, Ive been trying to get my application to "click" on a button in another application using SendMessage, Ive gotten this far but Im not sure whats wrong with this code, here is the whole application (its small for testing purposes) and it seems that window wraps the text, at least when I preview this post: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;
7
2230
by: Mike Barnard | last post by:
It's a simple test... VERY SIMPLE. But... In an external stlyesheet some attributes don't show. With the same styles cut and pasted to the test internally it works as expected. Anyone tell me why? Its probably sooooooo obvious, but it is 1.19 am! Thanks. www.thunderin.co.uk/
2
1456
mmarif4u
by: mmarif4u | last post by:
Hi Everyone. I have html page coding: HTML coding..... --------------------------------------------------- <h2>Search</h2> <form name="search" method="post" action="Search.php"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="fname">First Name</option>
1
7537
by: Abubakar | last post by:
Hi, In my application, Some of my thread gets stuck somewhere. The vs2k5 debugging "Thread" window shows that stuck thread and I can I dentify it. In its Name column the following text is written: "std::_Container_base::_Orphan_all". What does this mean? Now some general info about whats happnening here: :this is a call to a SendMessage api, which I'm sending to my GUI window, and this call never makes it back. I have checked the GUI...
5
2315
by: islayer | last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just the number. whats wrong with my code? #!/usr/bin/perl use Fcntl; @array = (a..z); srand; foreach (1..5) { $name = int(rand scalar(@array));
5
1715
by: hiqu | last post by:
This issue is driving me nuts and not able to figure out whats wrong. I've this code in my firefox extension. Firefox always hangs and reports the script is busy. if I introduce a break statement in the for(;;) loop below, then no issue. Any help would be appreciated! function getStuff()
0
8725
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8924
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7807
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4656
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3088
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.