Prev: OK my subform is not entering saving the key from the masterdatasource.
Next: code closing multiple reports
From: adamskiii on 27 Mar 2010 12:56 I have created an unbound form in Access 2007 and am listing the records which are in my table. I found out how to show how many records there are in the table but would also like to show which record you are on. For example, when I click the next button to see the next record it will show: "Record 2 Of 30", and so on. This is the one I used to count the amount of records: Dim countRecords As Long countRecords = DCount("customerNumber", "customer") Me.txtRecordAmount = "Record # Of " & countRecords How can I show what record I am on? Thanks
From: John W. Vinson on 27 Mar 2010 13:46 On Sat, 27 Mar 2010 09:56:05 -0700, adamskiii <adamskiii(a)discussions.microsoft.com> wrote: >I have created an unbound form in Access 2007 and am listing the records >which are in my table. I found out how to show how many records there are in >the table but would also like to show which record you are on. For example, >when I click the next button to see the next record it will show: "Record 2 >Of 30", and so on. This is the one I used to count the amount of records: > > Dim countRecords As Long > countRecords = DCount("customerNumber", "customer") > Me.txtRecordAmount = "Record # Of " & countRecords > >How can I show what record I am on? > >Thanks Since Tables have no defined order, and no record numbers, the question as posted has no answer. If you have a Recordset you could use its AbsolutePosition property; if you have a sorted query you could use DCount() to count the number of records with a key less than the current record's key. What's the context? Why are you using a (complex, less efficient, programming intensive) unbound form rather than a bound one, where all these come provided? -- John W. Vinson [MVP]
From: adamskiii on 27 Mar 2010 14:30 "John W. Vinson" wrote: > > Since Tables have no defined order, and no record numbers, the question as > posted has no answer. If you have a Recordset you could use its > AbsolutePosition property; if you have a sorted query you could use DCount() > to count the number of records with a key less than the current record's key. > What's the context? Why are you using a (complex, less efficient, programming > intensive) unbound form rather than a bound one, where all these come > provided? > -- > > John W. Vinson [MVP] > . > I just want it to show for example, if you are on the first record in the table then that is record 1, the next one is 2, and so on. I am using an unbound form because it helps me learn new things in Access. -Adam
From: John W. Vinson on 27 Mar 2010 16:19 On Sat, 27 Mar 2010 11:30:01 -0700, adamskiii <adamskiii(a)discussions.microsoft.com> wrote: >I just want it to show for example, if you are on the first record in the >table then that is record 1, the next one is 2, and so on. Again: A Table is an *unordered heap of records*. It does NOT contain record numbers. The order of records in the table is arbitrary, and Access does not expose it. If you have something you consider a "record number" then you must include it in the table as a field and maintain it yourself. The closest thing to it would be an Autonumber, but Autonumbers will have gaps in the sequence and can become random. >I am using an >unbound form because it helps me learn new things in Access. Just so you're aware that it's a much more complex and difficult approach than bound forms. It's sometimes necessary but I only use unbound forms when I must. -- John W. Vinson [MVP]
From: DevlinM on 27 Mar 2010 17:23 If you are just wanting to show the ordinal position of the cursor, you can use the form's CurrentRecord property in the Form_Current event. Private Sub Form_Current() Me.SomeTextBox = Me.CurrentRecord "adamskiii" wrote: > I have created an unbound form in Access 2007 and am listing the records > which are in my table. I found out how to show how many records there are in > the table but would also like to show which record you are on. For example, > when I click the next button to see the next record it will show: "Record 2 > Of 30", and so on. This is the one I used to count the amount of records: > > Dim countRecords As Long > countRecords = DCount("customerNumber", "customer") > Me.txtRecordAmount = "Record # Of " & countRecords > > How can I show what record I am on? > > Thanks
|
Next
|
Last
Pages: 1 2 Prev: OK my subform is not entering saving the key from the masterdatasource. Next: code closing multiple reports |