473,608 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determining first and last records displayed in a form

Lyn
I have a form set to Single Form mode with which I can cycle through the
records in a table via Next and Previous buttons. To avoid users pressing
the Previous button on the first record and the Next button on the last
record, I would like to disable one or both buttons when the first and/or
last record is displayed. I am not sure how to do this when the
RecordSource is simply the table.

I know that if the record source were a Recordset, I could use the
AbsolutePositio n and RecordCount properties, but in this case the record
source is not a recordset.

In another post, MacDermott drew my attention to the Recordset property of a
form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work
in the ADO environment.

The sort of code I am looking at for the Current event is:

If <recordset>.Abs olutePosition = 1 Then
Me!btnPrev.Enab led = False
Else
Me!btnPrev.Enab led = True
End If
If <recordset>.Abs olutePosition = <recordset>.Rec ordCount Then
Me!btnNext.Enab led = False
Else
Me!btnNext.Enab led = True
End If

Is using the form's Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error
13. Mismatch".)

Or is there a better approach than this?

Any help appreciated.
--
Cheers,
Lyn.
Nov 13 '05 #1
10 3723
On Mon, 24 Jan 2005 23:50:19 +1100, "Lyn" <lh******@ihug. com.au>
wrote:

The better approach may be to use the built-in navigation buttons.

If you have a REALLY good reason you need to run your own buttons, I
would suggest the form's RecordsetClone property:
set rs=me.recordset clone
rs.bookmark=me. bookmark ' sync rs with form
btnPrev.enabled = (rs.absolutepos ition>1)
set rs=nothing

-Tom.

I have a form set to Single Form mode with which I can cycle through the
records in a table via Next and Previous buttons. To avoid users pressing
the Previous button on the first record and the Next button on the last
record, I would like to disable one or both buttons when the first and/or
last record is displayed. I am not sure how to do this when the
RecordSource is simply the table.

I know that if the record source were a Recordset, I could use the
AbsolutePositi on and RecordCount properties, but in this case the record
source is not a recordset.

In another post, MacDermott drew my attention to the Recordset property of a
form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work
in the ADO environment.

The sort of code I am looking at for the Current event is:

If <recordset>.Abs olutePosition = 1 Then
Me!btnPrev.Enab led = False
Else
Me!btnPrev.Enab led = True
End If
If <recordset>.Abs olutePosition = <recordset>.Rec ordCount Then
Me!btnNext.Enab led = False
Else
Me!btnNext.Enab led = True
End If

Is using the form's Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error
13. Mismatch".)

Or is there a better approach than this?

Any help appreciated.


Nov 13 '05 #2
rkc
Lyn wrote:
I have a form set to Single Form mode with which I can cycle through the
records in a table via Next and Previous buttons. To avoid users pressing
the Previous button on the first record and the Next button on the last
record, I would like to disable one or both buttons when the first and/or
last record is displayed. I am not sure how to do this when the
RecordSource is simply the table.

I know that if the record source were a Recordset, I could use the
AbsolutePositio n and RecordCount properties, but in this case the record
source is not a recordset.

In another post, MacDermott drew my attention to the Recordset property of a
form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work
in the ADO environment.

The sort of code I am looking at for the Current event is:

If <recordset>.Abs olutePosition = 1 Then
Me!btnPrev.Enab led = False
Else
Me!btnPrev.Enab led = True
End If
If <recordset>.Abs olutePosition = <recordset>.Rec ordCount Then
Me!btnNext.Enab led = False
Else
Me!btnNext.Enab led = True
End If

Is using the form's Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error
13. Mismatch".)


Zero is the first record position.
..RecordCount -1 is the last record position.

Nov 13 '05 #3
Lyn
I think that applies to DAO. I am using ADO and according to the Help file,
the first record is 1 and -1 means adPosUnknown. Very confusing!

--
Cheers,
Lyn.

"rkc" <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in message
news:%_******** ***********@twi ster.nyroc.rr.c om...
Zero is the first record position.
.RecordCount -1 is the last record position.

Nov 13 '05 #4
Lyn
Tom,
Thanks for the advice -- I will try it out.

--
Cheers,
Lyn.

"Tom van Stiphout" <no************ *@cox.net> wrote in message
news:ae******** *************** *********@4ax.c om...
On Mon, 24 Jan 2005 23:50:19 +1100, "Lyn" <lh******@ihug. com.au>
wrote:

The better approach may be to use the built-in navigation buttons.

If you have a REALLY good reason you need to run your own buttons, I
would suggest the form's RecordsetClone property:
set rs=me.recordset clone
rs.bookmark=me. bookmark ' sync rs with form
btnPrev.enabled = (rs.absolutepos ition>1)
set rs=nothing

-Tom.

Nov 13 '05 #5

"Lyn" <lh******@ihug. com.au> wrote
In another post, MacDermott drew my attention to the Recordset property of a form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work in the ADO environment. [snip] Is using the form's Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error 13. Mismatch".)


Just to be sure, but you are using an ADP, right? Because the recordset of
an mdb uses DAO - you can't set a DAO recordset to an ADO recordset.
Darryl Kerkeslager
Nov 13 '05 #6
rkc
Lyn wrote:
I think that applies to DAO. I am using ADO and according to the Help file,
the first record is 1 and -1 means adPosUnknown. Very confusing!


Why think. Try it. It's real simple.

Put a textbox on your form and in the form's current event set it's
value to Me.Recordset.Ab solutPosition. When you are on the first
record the value will be zero. When you are on the last record the
value will be 1 less than Me.Recordset.co unt.
Nov 13 '05 #7
Lyn
OK, this really had me confused for a few minutes. But I think I have it
figured out. I have been using the ADO library for my own recordsets. The
Help file specifically says that AbsolutePositio n is "1-based".

Using the reference that you suggested (Me.Recordset.A bsolutePosition ), I am
in fact accessing the form's "internal" recordset -- if that is the right
way to put it. And it seems that "internally " Access uses DAO where
AbsolutePositio n is "0-based".

This was an interesting and educational exercise. Thanks for your input.

--
Cheers,
Lyn.

"rkc" <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in message
news:S8******** *****@twister.n yroc.rr.com...

Put a textbox on your form and in the form's current event set it's
value to Me.Recordset.Ab solutPosition. When you are on the first
record the value will be zero. When you are on the last record the
value will be 1 less than Me.Recordset.co unt.

Nov 13 '05 #8
Lyn
I am using an mdb. Something that has only just become clear to me is that
Access forms use DAO. When creating your own recordsets, you are free to
use the DAO or ADO libraries and formats. But it seems that Access forms
have DAO built in, so that properties like .Recordset are in DAO format, and
there is no option to change it to ADO.

As you have probably guessed, I am new to Access. A couple of the manuals
that I have used suggested that ADO is the way of the future and recommended
that new projects should use ADO. One even suggested that DAO may be phased
out in future versions of Access. Hence I decided to use ADO for my
projects.

I don't want to open a can of worms with this -- I know that there strong
arguments in favour of both types and each has its loyal adherents. I am
just explaining why I chose to learn and use ADO, and that I now realise
that I also have to deal with DAO where Access seems to use it internally.

--
Cheers,
Lyn.

"Darryl Kerkeslager" <Ke*********@co mcast.net> wrote in message
news:kt******** ************@co mcast.com...

Just to be sure, but you are using an ADP, right? Because the recordset
of
an mdb uses DAO - you can't set a DAO recordset to an ADO recordset.
Darryl Kerkeslager

Nov 13 '05 #9
> "Darryl Kerkeslager" <Ke*********@co mcast.net> wrote
Just to be sure, but you are using an ADP, right? Because the recordset
of an mdb uses DAO - you can't set a DAO recordset to an ADO recordset.
"Lyn" <lh******@ihug. com.au> wrote I am using an mdb. Something that has only just become clear to me is that Access forms use DAO. When creating your own recordsets, you are free to
use the DAO or ADO libraries and formats. But it seems that Access forms
have DAO built in, so that properties like .Recordset are in DAO format, and there is no option to change it to ADO.

As you have probably guessed, I am new to Access. A couple of the manuals
that I have used suggested that ADO is the way of the future and recommended that new projects should use ADO. One even suggested that DAO may be phased out in future versions of Access. Hence I decided to use ADO for my
projects.

I have used ADO since I started seriously using Access, and my only problem
with ADO was a lack of good examples. At this point, I see no real
difference in either technology. Both are adequate to the task, and both
may/will be phased out. The issue of mdb forms, and the inabilty to
manipulate mdb objects, are the only significant negatives of ADO. BTW, you
can manipulate tables, columns, indexes, groups, users, etc - just not
objects specific to mdb files.

I have also been in the habit since day one of fully qualifying all ADODB
and DAO references. It makes life easier, and perhaps makes your code
..00001 seconds faster.
Darryl Kerkeslager
Nov 13 '05 #10

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

Similar topics

0
2172
by: Duke Hamacher | last post by:
Hello: This title is a little ambiguous but this is an interesting puzzle. Lets's say we have a JSP page with a form. The ActionForm associated with this form has, say, 4 String properities. Very simple. Remember, we only have one form. Now let's say each the 4 String properties together comprise a record and the user is able to view and edit a variable number of records at
10
17489
by: Alain Guichaoua | last post by:
Good evening to all Here is my problem : I have a form with a subform. They are linked. When I open the form I would like the subform to reach its last record. I tried the method docmd.gotorecord aclast but i did not
4
7041
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm, "frmReportOptions" <== popup form This is the error I get when I try to move to the last page of the report *after* closing the popup: "This expression is typed incorectly, or is too complex to be evaluate...."
2
7551
by: Ryan | last post by:
Access97 I hope someone out there can help. This is driving me crazy. Basically, I am trying to recreate VBA's built in navigation feature (The one that allows you to move first, next, previous, and last and also tells you that you are on Record # or . The navigation part was easy. My problem is determing the what record I am on and the total number of records. I put the following code into the my subforms on Current event:
2
1765
by: trgpham | last post by:
hi all, I have a continuous form that bound to a couple of fields. When the records are displayed, the last record which have nothing also display (blank record). I tried to Group it in the record set, it works, but I won't be able to modify the fields bounded onto the form. How do I make this not displaying and also able to edit the exisiting records? Many thanks for any help. regards,
3
2419
by: brucedodds | last post by:
My application has a form based on a parent table with a subform based on a child table. The relationship is Cascade Delete. The first record displayed when the form opens has five child records. The form allows this record to be deleted without a prompt, though SetWarnings is set to True. When you try to delete other records, you do get a prompt. The problem isn't the relationship or the tables, because a test form/ subform using the...
7
6572
by: robtyketto | last post by:
Greetings, I have a main form. Upon filling in a combo box it then displays a subform (based on a query that uses values in the combo box on where clause) THe subform has the paramater Data Entry = 'No' as I want users to see all existing records and all additions/deletions and edits. However I want to move to the last record to default, allowing the user to add a record without navigating themselves to the last record. A popular...
3
2227
by: Gord | last post by:
If I have a form open with a subform control on it in datasheet view that has its record source set to a query or a table, is it possible to determine which record the user has clicked into with VB? I don't mean the text box with which you can determine the field/column, but the record (row). I guess what I'm looking for would be the bookmark? (or some line numbering?) or whatever information would aid in determining unambiguously which...
0
7987
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
8464
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8324
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...
1
6000
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
5471
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();...
0
3954
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
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2464
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
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.