473,385 Members | 1,641 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.

A97: Can I 'peek' to see if there is another record?

MLH
Before running the following line of code, I would like to first know
if there is another record in the form's record source. If I run this
line when the last record is current, an error is returned. Any way
to take a peek first?

DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext
Nov 13 '05 #1
8 1910
MLH wrote:
Before running the following line of code, I would like to first know
if there is another record in the form's record source. If I run this
line when the last record is current, an error is returned. Any way
to take a peek first?

DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext


I would have thought the next record would be a new one if you were on
the last <shrug>

Not tested but you might try using something like:
with me.recordsetclone
if (.AbsolutePosition+1) < .Recordcount then
DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext
else
' whatever you want to let user know
end if
end with

Note:
..AbsolutePosition is zero based so when it says 0 you're on record 1
therefore you always have to add 1 to it.

--
[OO=00=OO]
Nov 13 '05 #2
MLH wrote:
Before running the following line of code, I would like to first know
if there is another record in the form's record source. If I run this
line when the last record is current, an error is returned. Any way
to take a peek first?

DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext


Something like this might work

Dim rst As Recordset
Set rst = Me.RecordsetClone
If rst.recordcount > 0 then
rst.MoveLast 'get form's record count
rst.Bookmark = Me.Bookmark
If (rst.RecordCount <> rst.AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext
End If
endif
Set rst = Nothing

Nov 13 '05 #3
Salad <oi*@vinegar.com> wrote in
news:wm**************@newsread1.news.pas.earthlink .net:
MLH wrote:
Before running the following line of code, I would like to first
know if there is another record in the form's record source. If I
run this line when the last record is current, an error is
returned. Any way to take a peek first?

DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext


Something like this might work

Dim rst As Recordset
Set rst = Me.RecordsetClone
If rst.recordcount > 0 then
rst.MoveLast 'get form's record count
rst.Bookmark = Me.Bookmark
If (rst.RecordCount <> rst.AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts",
acNext End If
endif
Set rst = Nothing


Ack! Why do all of you continue to write code like this?

There is absolutely no need to set a recordset variable to refer to
something that can be done with a WITH block:

With Me.RecordsetClone
If .recordcount > 0 then
.MoveLast 'get form's record count
.Bookmark = Me.Bookmark
If (.RecordCount <> .AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, _
"frmEnterLienAmounts", acNext
End If
End If
End With

This avoids needing to declare a variable, assign a recordset to it,
and then clean up after it.

What's not to like?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4

David W. Fenton wrote:
Ack! Why do all of you continue to write code like this?

There is absolutely no need to set a recordset variable to refer to
something that can be done with a WITH block:

With Me.RecordsetClone
If .recordcount > 0 then
.MoveLast 'get form's record count
.Bookmark = Me.Bookmark
If (.RecordCount <> .AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, _
"frmEnterLienAmounts", acNext
End If
End If
End With

This avoids needing to declare a variable, assign a recordset to it,
and then clean up after it.

What's not to like?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


Your point is well taken David. Perhaps we didn't know that
intellisense would work on a . inside the With..End With block? I'm
resolving to use With..End With more often. It does make things
slightly more readable. Setting rst for a RecordsetClone is more of a
habit that I will outgrow now that I know it's not required. I learned
several years ago that I was tying my shoes with the equivalent of a
granny knot rather than a square knot. I was able to relearn how to
tie my shoes properly. I'll be able to incorporate new Access
programming techniques although at this level it's mostly a matter of
style and mental organization (still necessary) rather than of making a
huge performance difference or a great conceptual leap. Thanks for the
reminder. Your comments are appreciated.

James A. Fortune

Nov 13 '05 #5
rkc
David W. Fenton wrote:
Salad <oi*@vinegar.com> wrote in
news:wm**************@newsread1.news.pas.earthlink .net:

MLH wrote:
Before running the following line of code, I would like to first
know if there is another record in the form's record source. If I
run this line when the last record is current, an error is
returned. Any way to take a peek first?

DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext


Something like this might work

Dim rst As Recordset
Set rst = Me.RecordsetClone
If rst.recordcount > 0 then
rst.MoveLast 'get form's record count
rst.Bookmark = Me.Bookmark
If (rst.RecordCount <> rst.AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts",
acNext End If
endif
Set rst = Nothing

Ack! Why do all of you continue to write code like this?

There is absolutely no need to set a recordset variable to refer to
something that can be done with a WITH block:

With Me.RecordsetClone
If .recordcount > 0 then
.MoveLast 'get form's record count
.Bookmark = Me.Bookmark
If (.RecordCount <> .AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, _
"frmEnterLienAmounts", acNext
End If
End If
End With

This avoids needing to declare a variable, assign a recordset to it,
and then clean up after it.

What's not to like?


What's your point? That the operations can be done using recordsetclone
without setting a new variable equal to it or that the With statement
is magical?


Nov 13 '05 #6
David W. Fenton wrote:
Salad <oi*@vinegar.com> wrote in
news:wm**************@newsread1.news.pas.earthlink .net:

MLH wrote:
Before running the following line of code, I would like to first
know if there is another record in the form's record source. If I
run this line when the last record is current, an error is
returned. Any way to take a peek first?

DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts", acNext


Something like this might work

Dim rst As Recordset
Set rst = Me.RecordsetClone
If rst.recordcount > 0 then
rst.MoveLast 'get form's record count
rst.Bookmark = Me.Bookmark
If (rst.RecordCount <> rst.AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, "frmEnterLienAmounts",
acNext End If
endif
Set rst = Nothing

Ack! Why do all of you continue to write code like this?

There is absolutely no need to set a recordset variable to refer to
something that can be done with a WITH block:

With Me.RecordsetClone
If .recordcount > 0 then
.MoveLast 'get form's record count
.Bookmark = Me.Bookmark
If (.RecordCount <> .AbsolutePosition + 1) Then
DoCmd.GoToRecord acActiveDataForm, _
"frmEnterLienAmounts", acNext
End If
End If
End With

This avoids needing to declare a variable, assign a recordset to it,
and then clean up after it.

What's not to like?

I figured if someone had a better solution it would be presented. I
write most of my stuff on the fly and hope for the best.
Nov 13 '05 #7
rkc wrote:
What's your point? That the operations can be done using recordsetclone
without setting a new variable equal to it or that the With statement
is magical?


It is magical, with this method you can actually fix something that
isn't broken... without breaking it :-)

--
[OO=00=OO]
Nov 13 '05 #8
Trevor Best <no****@besty.org.uk> wrote in
news:42**********************@news.zen.co.uk:
rkc wrote:
What's your point? That the operations can be done using
recordsetclone
without setting a new variable equal to it or that the With
statement
is magical?


It is magical, with this method you can actually fix something
that isn't broken... without breaking it :-)


It's less code, and code that doesn't require creating a new memory
structure, and then cleaning up after it.

Again, what's not to like?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9

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

Similar topics

2
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks...
22
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make...
3
by: Pieter Linden | last post by:
I have a database of rental units etc that I'm using the CreateTableFromRecordset code from ADH 2000. Well, at the moment, I'm doing a sanity check and testing it on my computer, with A2002, but...
1
by: Andrew Chanter | last post by:
I developed 3 different replicated database applications in MS Access for 3 different corporate clients in Access 97 several years ago to enable data to be shared across wide area networks. I...
6
by: MLH | last post by:
If I open an A97 table, resort its key-field to descending order and attempt to close the table, A97 asks me if I wish to save the table DESIGN? Now really, I don't think the table design is being...
9
by: MLH | last post by:
Trouble is, it doesn't happen every time. Yesterday, for example, it happened only once and not again afterward. Some days ago, a similar situation. Today, well - I tried 7 times straight to open...
10
by: MLH | last post by:
If I wanted 2 of each page, could I make them print out 2 of first page, 2 of second page, 2 of third page, 2 of fourth page and 2 of 5th page? Or, do I have to run the openreport method twice...
3
by: Salad | last post by:
Using A97, SP2, most current jet35. I have a search form. The op enters an id to search/find. If found, a data entry form is presented for that id. This form has 7 or 8 combos, a bunch of...
2
by: MLH | last post by:
I have an A97 form with Allow Edits, Allow Deletions and Allow Additions properties set. Scrolling through records will eventually take me to the end of the records and one more PgDn will take me...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.