473,766 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

do i NEED to use .movefirst immediately upon opening a recordset?

MLH
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one record,
the first record is the current record and the BOF and EOF properties
are False; they remain False until you move beyond the beginning or
end of the Recordset object by using the MovePrevious or MoveNext
method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the lines
below is simply not needed. Would you agree? Am I incorrect?

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
If .BOF = True Then GoTo NoRecs
.MoveFirst
Do Until rstRRs.EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait = True
...

I would like to take the .MoveFirst out if it is not needed.
May 20 '06 #1
7 6531
MLH wrote:
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one record,
the first record is the current record and the BOF and EOF properties
are False; they remain False until you move beyond the beginning or
end of the Recordset object by using the MovePrevious or MoveNext
method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the lines
below is simply not needed. Would you agree? Am I incorrect?

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
If .BOF = True Then GoTo NoRecs
.MoveFirst
Do Until rstRRs.EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait = True
...

I would like to take the .MoveFirst out if it is not needed.


I've never used MoveFirst in a situation like that. You can get rid of it.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 20 '06 #2
MLH
I was hoping you'd say that.
Many thanks!
May 20 '06 #3
MLH <CR**@NorthStat e.net> wrote in
news:dd******** *************** *********@4ax.c om:
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one
record, the first record is the current record and the BOF and
EOF properties are False; they remain False until you move
beyond the beginning or end of the Recordset object by using
the MovePrevious or MoveNext method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the
lines below is simply not needed. Would you agree? Am I
incorrect?

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
If .BOF = True Then GoTo NoRecs
.MoveFirst
Do Until rstRRs.EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait =
True ...

I would like to take the .MoveFirst out if it is not needed.

Yes: the .Movefirst is useless. It will even raise an error if
the recordset type is dbOpenForwardOn ly
You may also be able to delete the IF .BOF statement if the
NoRecs:label immediately follows your do loop.

--
Bob Quintal

PA is y I've altered my email address.
May 20 '06 #4
On Sat, 20 May 2006 08:30:28 -0400, MLH <CR**@NorthStat e.net> wrote:

Since after opening a recordset the record pointer is already at the
first record (if at least 1 record), it is a no-op. As Bob points
out, it is even counter-productive in some situations.

-Tom.
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one record,
the first record is the current record and the BOF and EOF properties
are False; they remain False until you move beyond the beginning or
end of the Recordset object by using the MovePrevious or MoveNext
method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the lines
below is simply not needed. Would you agree? Am I incorrect?

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
If .BOF = True Then GoTo NoRecs
.MoveFirst
Do Until rstRRs.EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait = True
...

I would like to take the .MoveFirst out if it is not needed.


May 20 '06 #5
"Rick Brandt" <ri*********@ho tmail.com> wrote in
news:b%******** **********@news svr11.news.prod igy.com:
MLH wrote:
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one
record, the first record is the current record and the BOF and
EOF properties are False; they remain False until you move beyond
the beginning or end of the Recordset object by using the
MovePrevious or MoveNext method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the
lines below is simply not needed. Would you agree? Am I
incorrect?

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
If .BOF = True Then GoTo NoRecs
.MoveFirst
Do Until rstRRs.EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait = True
...

I would like to take the .MoveFirst out if it is not needed.


I've never used MoveFirst in a situation like that. You can get
rid of it.


I never use BOF/EOF to test for an empty recordset, but instead use
RecordCount = 0 (one test is more efficient than two).

But I always explicitly .MoveFirst simply because I don't like
depending on something happening over which I have no control. It
can't possibly be a performance problem since it's only going to
happen once per recordset, so I don't see the issue with doing
something explicitly that may be slightly redundant.

I simply don't like assuming that things will work the way they are
supposed in all situations.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
May 21 '06 #6

MLH wrote:
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one record,
the first record is the current record and the BOF and EOF properties
are False; they remain False until you move beyond the beginning or
end of the Recordset object by using the MovePrevious or MoveNext
method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the lines
below is simply not needed. Would you agree? Am I incorrect?


You are correct.
Chirag Shukla.

May 21 '06 #7
The .MoveFirst is less of a problem than the
If .BOF = True Then GoTo NoRecs

You should not use GoTo unless absolutely forced to, it creates spaghetti
code which can easily become very difficult to debug.

The .MoveFirst is not necessary. without it (and after removing the GoTo
line) your code becomes

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
Do Until .EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait = True
Without knowing the rest of your code it's not possible to recommend how to
handle the situation where the recordset is empty.

--

Terry Kreft
"MLH" <CR**@NorthStat e.net> wrote in message
news:dd******** *************** *********@4ax.c om...
Here's a blurb cut from A97 HELP on BOF/EOF:
When you open a Recordset object that contains at least one record,
the first record is the current record and the BOF and EOF properties
are False; they remain False until you move beyond the beginning or
end of the Recordset object by using the MovePrevious or MoveNext
method, respectively.

From that HELP blurb, it would seem that the .MoveFirst in the lines
below is simply not needed. Would you agree? Am I incorrect?

Set rstRRs = .OpenRecordset( dbOpenSnapshot)
With rstRRs
If .BOF = True Then GoTo NoRecs
.MoveFirst
Do Until rstRRs.EOF
If Int(Now()) - !DateSigned < WaitTime Then GottaWait = True
...

I would like to take the .MoveFirst out if it is not needed.

May 21 '06 #8

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

Similar topics

5
7408
by: shank | last post by:
Can anyone give me some general ideas on why an error like Object doesn't support this property or method: 'ZoneRS.MoveFirst' comes up on a page? MoveFirst is a command to move to the first record... correct? thanks
2
1793
by: Lin Ma | last post by:
Hello, I have a general question. In my asp page, I have DB connection, Recordset, and some variables like dim name, conn, rs set conn = Server.CreateObject("ADODB.Connection") .... set rs= server.createObject("ADODB.Recordset")
0
2410
by: (Pete Cresswell) | last post by:
I've been plagued by these over the years. The text is something to the effect of "Object doesn't exist". Today I started getting the error upon opening a multi-subform form that's been working since day 1. Stepping through the code, I found the subform that was causing the problem. If the parent form is then opened in design mode and then re-opened, the error does not happen. Next time the app is started up from scratch, it...
1
3337
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently overwhelmed by useless examples across the web on how to make "dynamic crosstab reports" without myself having a basic understanding about how to retrieve and assign recordsources, etc., from fields in a query to fields in the report. I see all these...
5
25462
by: tony010409020622 | last post by:
I just spent 4 months taking a dotnet class where i learned very little. One of the things I did not learn is this: What are the dotnet equivilents of commands such as: Adodc1.Recordset.AddNew Adodc1.Recordset.Update Adodc1.Recordset.MoveFirst Adodc1.Recordset.MoveNext Adodc1.Recordset.Delete
3
4914
by: MLH | last post by:
The error occurred in line #5130. Ideas as to why? qryITSLetterList returns 1 single record - but I don't think that should be a problem. Hmmm??? 5100 Dim MyDB As Database, rstITSLttrs As Recordset, rstOtherTable As Recordset 5110 Set MyDB = CurrentDb() 5120 Set rstITSLttrs = MyDB.OpenRecordset("qryITSLetterList", dbOpenForwardOnly) 5130 rstITSLttrs.MoveFirst
6
2482
by: kenshiro | last post by:
Hi All, I'm having a problem with some VBA code in one of my Access 2003 databases. I'm getting the following error when running code behind a command button on a form: "Item not found in this collection". I suspect it has something to do with parameters in the query I'm calling. I need to pass an object on the form to a parameter in the query, and the query is quite complex as well. Here is the query:
4
8677
by: felicia | last post by:
Hi All, Below is my code to delete records: adodcAllEntries.Recordset.MoveFirst Do While (adodcAllEntries.Recordset.EOF = False) If adodcAllEntries.Recordset.Fields(0) = selected_id Then adodcAllEntries.Recordset.Delete End If
4
11061
by: MLH | last post by:
160 Dim DB As Database, Rst As Recordset, QD As QueryDef 170 Set DB = CurrentDb() 180 Set QD = DB.CreateQueryDef("", MySQL) 190 Set Rst = QD.OpenRecordset(dbOpenDynaset) HOW TO COUNT RECORDS IN Rst BEFORE NEXT LINE? 200 Rst.MoveFirst
0
9571
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
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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
9838
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
8835
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...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.