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

recordsets - problem

Consider this code please:

Private Sub Command17_Click()

Dim Db As DAO.Database
Dim Rec As DAO.Recordset
Dim TotMins As Integer

Set Db = CurrentDb()
Set Rec = Db.OpenRecordset("Tbl_PlayerMatch", dbOpenDynaset)

Do Until Rec.EOF
TotMins = TotMins + Rec!MinutesPlayed
Rec.MoveNext
Loop

Rec.Close

End Sub
Why is it that

1) <out of context> is displayed when I debug on Rec!MinutesPlayed.
2) Seems to read past EOF. Displays <out of context> for TotMins and
Rec!MinutesPlayed after last rec processed. Can't not get Totmins
displayed because of this

Many thanks
Geoff
Nov 12 '05 #1
1 1492
"Geoff" <g.*****@ntlworld.com> wrote in message
news:eTO0c.2128$GQ.834@newsfe1-win...
Consider this code please:

Private Sub Command17_Click()

Dim Db As DAO.Database
Dim Rec As DAO.Recordset
Dim TotMins As Integer

Set Db = CurrentDb()
Set Rec = Db.OpenRecordset("Tbl_PlayerMatch", dbOpenDynaset)

Do Until Rec.EOF
TotMins = TotMins + Rec!MinutesPlayed
Rec.MoveNext
Loop

Rec.Close

End Sub
Why is it that

1) <out of context> is displayed when I debug on Rec!MinutesPlayed.
2) Seems to read past EOF. Displays <out of context> for TotMins and
Rec!MinutesPlayed after last rec processed. Can't not get Totmins
displayed because of this

Many thanks
Geoff


A few thoughts:
Any reason not to simply use a DSUM function?
Are you sure MinutesPlayed cannot contain a null value? Because, for
example, 25 + Null = Null, it is common practice to use the Nz function, if
this is the case.
For these sort of loops do you not include some generic error handling?
Common practice in this newsgroup is to set object variables to nothing as a
final step before exiting a sub.
Fletcher
Nov 12 '05 #2

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

Similar topics

7
by: (Pete Cresswell) | last post by:
I posted this in the MS Access group, but no luck. ------------------------------------------ I've got another stored procedure in the same app that returns multiple recordsets and the code works....
2
by: Toonman | last post by:
I have a single .asp page that opens a connection and then sequentially opens and closes 14 recordsets from stored procedures to obtain various product information before closing the connection. ...
22
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to...
6
by: Steve Jorgensen | last post by:
I keep having problems in which ADO disconnected recordset work under some circumstances, but lose all their data at other times, having no rows or fields, though the recordset object still exists....
2
by: Pieter Linden | last post by:
The answer to this one is probably "test it yourself and find out!", but I'll ask anyway. Pursuant to my previous question - sending separate recordsets to Word using the CreateTableFromRecordset...
1
by: lakshmi | last post by:
Hi all, I recently rewrote a data intensive C++ program in C#. The C++ program was traversing 3 recordsets that were all open at the same time. I replaced those 3 recordsets with 3 .NET data...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
4
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I...
4
by: rdemyan via AccessMonster.com | last post by:
Can someone help me with creating code that will look for DAO recordsets in modules and then check to see if the recordset is also closed in the module. All of my recordsets are of the form rs*...
1
by: sphinney | last post by:
As my Access form opens, I want it to find the names of the tables in the current Access database and populate a combobox with the table (recordset) names. Problem is, the CurrentDb.Recordsets...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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
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.