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
AbsolutePosition 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>.AbsolutePosition = 1 Then
Me!btnPrev.Enabled = False
Else
Me!btnPrev.Enabled = True
End If
If <recordset>.AbsolutePosition = <recordset>.RecordCount Then
Me!btnNext.Enabled = False
Else
Me!btnNext.Enabled = 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. 10 3585
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.recordsetclone
rs.bookmark=me.bookmark ' sync rs with form
btnPrev.enabled = (rs.absoluteposition>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 AbsolutePosition 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>.AbsolutePosition = 1 Then Me!btnPrev.Enabled = False Else Me!btnPrev.Enabled = True End If If <recordset>.AbsolutePosition = <recordset>.RecordCount Then Me!btnNext.Enabled = False Else Me!btnNext.Enabled = 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.
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 AbsolutePosition 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>.AbsolutePosition = 1 Then Me!btnPrev.Enabled = False Else Me!btnPrev.Enabled = True End If If <recordset>.AbsolutePosition = <recordset>.RecordCount Then Me!btnNext.Enabled = False Else Me!btnNext.Enabled = 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.
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:%_*******************@twister.nyroc.rr.com... Zero is the first record position. .RecordCount -1 is the last record position.
Tom,
Thanks for the advice -- I will try it out.
--
Cheers,
Lyn.
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:ae********************************@4ax.com... 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.recordsetclone rs.bookmark=me.bookmark ' sync rs with form btnPrev.enabled = (rs.absoluteposition>1) set rs=nothing
-Tom.
"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
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.AbsolutPosition. 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.count.
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 AbsolutePosition is "1-based".
Using the reference that you suggested (Me.Recordset.AbsolutePosition), 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
AbsolutePosition 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.nyroc.rr.com... Put a textbox on your form and in the form's current event set it's value to Me.Recordset.AbsolutPosition. 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.count.
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*********@comcast.net> wrote in message
news:kt********************@comcast.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
> "Darryl Kerkeslager" <Ke*********@comcast.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
Interesting thought -- has anybody ever come up with a function that will
convert an ADO recordset and related objects to DAO, and vice versa?
--
Cheers,
Lyn. The issue of mdb forms, and the inabilty to manipulate mdb objects, are the only significant negatives of ADO. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |