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

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 6476
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**@NorthState.net> wrote in
news:dd********************************@4ax.com:
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 dbOpenForwardOnly
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**@NorthState.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*********@hotmail.com> wrote in
news:b%******************@newssvr11.news.prodigy.c om:
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**@NorthState.net> wrote in message
news:dd********************************@4ax.com...
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
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...
2
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=...
0
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...
1
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...
5
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...
3
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...
6
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...
4
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...
4
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
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
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...

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.