473,406 Members | 2,633 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,406 software developers and data experts.

Display the number of records found

42
Hi guys - one more problem i couldn't figure it out .

I have a form which displays a set of records and i want to display on top of the form the number of the record the user is looking at out of the total records .

I hope u understand what i'm looking for .
for example i want to display something like this

" record : 1 out of 50 found "

i know how to display the total cose is just a count of all records but what about the "1" how do i make it to display and to incremet each time the user clicks to see the next record?

Thanks
May 19 '09 #1
22 4581
ADezii
8,834 Expert 8TB
@onyris
You can use the CurrentRecord Property of a Form to identify the Current Record in the Recordset being viewed, as in:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![lblRecordNumber].Caption = "Record Number " & Me.CurrentRecord
  3. End Sub
May 19 '09 #2
NeoPa
32,556 Expert Mod 16PB
This number will not always be predictable. Even if it is, it is not something that will be much help to refer to. I suggest you'd be better off displaying a field, such as the PK, which will uniquely reference the record.

Finding record #X in future will often return a different record, depending on a number of variables.
May 19 '09 #3
onyris
42
You can use the CurrentRecord Property of a Form to identify the Current Record in the Recordset being viewed
Thanks man , that's exactly what i needed .
May 19 '09 #4
ADezii
8,834 Expert 8TB
@NeoPa
Just for curiosity NeoPa, how is CurrentRecord not predictable? It corresponds exactly to the Value shown in the Record Number Box on a Form and will also reflect the Absolute Position relative to the Form's Data Source. I realize that it is not a Unique Reference to a specific Record, but that is not why this Property exists.
May 19 '09 #5
NeoPa
32,556 Expert Mod 16PB
@ADezii
Well, the answer's in your question from my perspective.

Deletions (and additions in fact in some cases) can effect which record is where within a particular data source.

A single table can have various indices. Each would reflect a different order, and therefore relative position. This may not effect an individual form in a single instance, but assuming nothing will change is not something I would ever advise.
@ADezii
Exactly why I recommend it not be used that way.
May 19 '09 #6
ADezii
8,834 Expert 8TB
@NeoPa
Sorry NeoPa, but I think you are over-analyzing the concept. Sometimes it is not relevant which Record is where within a particular Data Source, but Record Number X of X Records within the Data Source is. Oh well, always a pleasure.
May 19 '09 #7
NeoPa
32,556 Expert Mod 16PB
You're possibly right ADezii, but that way I avoid possible problems later on. If the problem isn't there all I've lost is a little time analysing in the first place.

As a practice though, I find it helps. At the end of the day, we all need to choose ways we're happiest working with. I'm possibly a tad over-analytical by nature, but I don't remember it getting me into any trouble anywhen.

PS. You know I always enjoy discussing things with you. We may disagree on some things, but that's how ideas get shared. Always beneficial in my view.
May 20 '09 #8
onyris
42
Guys , one more question

When the form is loaded is displaying the number of records out of the total records. This is fine , but now when i select a different record from the List box
the current record number remains the same (doesn't change).

I have tried to build an If statement and is not working.I'll put the code below if you could tell me what is wrong.
I am not sure what the index number is if nothig is selected from the listbox.
Expand|Select|Wrap|Line Numbers
  1. if List49.Selected =null
  2. Me![Label37].Caption = Me.CurrentRecord
  3. else 
  4. Me![Label37].Caption = List49.Selected
May 20 '09 #9
ADezii
8,834 Expert 8TB
@onyris
but now when i select a different record from the List box
the current record number remains the same (doesn't change).
Not really sure what you mean.
May 20 '09 #10
onyris
42
Not really sure what you mean.
I'll try to explain again.

when the form opens , this is the code used to display current record in the recordset being viewed :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Me![Label37].Caption = Me.CurrentRecord
  3.  
  4. End Sub
The same record set is stored in a List box.
for example the record set contains 3 records
At the begining is displayed
" Record 1 of 3 found"

then when i click on the third record from the listbox to display this
" Record 3 of 3 found"

this is what i want with words
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. if ( nothing selected in the listbox)
  3. Me![Label37].Caption = Me.CurrentRecord
  4. else( get the index number of the selected record and display it )
  5. End Sub
Hope it make sense now , if not let me know and i'll try again.
Sorry about the way i explain the issues.
May 20 '09 #11
ADezii
8,834 Expert 8TB
@onyris
I'm a little slow this Week, no this Month, well actually this Year. In any event, try the following which assumes a List Box named List49 ,a Label Control named Label37, and the MultiSelect Property of the List Box = None:
Expand|Select|Wrap|Line Numbers
  1. 'A ListIndex of -1 indicates that 'No Item was Selected'
  2. If Me![List49].ListIndex = -1 Then
  3.   Me![Label37].Caption = Me.CurrentRecord
  4. Else
  5.   'ListIndex Property is Zero based, so add 1 if necessary
  6.   Me![Label37].Caption = Me![List49].ListIndex + 1
  7. End If
May 20 '09 #12
onyris
42
I have tried that and now i get this error :

Compile error: Syntax error on this line

If Me![List49].ListIndex = -1 Then

Any ideea?
May 21 '09 #13
ADezii
8,834 Expert 8TB
@onyris
Is your List Box named List49?
May 21 '09 #14
onyris
42
Yes it is i've checked again.
May 21 '09 #15
onyris
42
I have added an "end if " at the end and is not giving any errors now , but is not displaying the number on the label.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me![List49].ListIndex = -1 Then
  3. Me![Label37].Caption = Me.CurrentRecord
  4. Else
  5. Me![Label37].Caption = Me![List49].ListIndex + 1
  6. End If
  7. End Sub
Anything wrong with the code?
May 21 '09 #16
ADezii
8,834 Expert 8TB
@onyris
Are you sure that your Label is named Label37, and in fact it is a Label, and not a Text Box Control since a Text Box does not have a Caption Property?
May 21 '09 #17
onyris
42
Are you sure that your Label is named Label37, and in fact it is a Label, and not a Text Box Control since a Text Box does not have a Caption Property?
Yes , 100%.

The code is in Form_current().
this is the right place or it should be in the Form_load()?
May 21 '09 #18
ADezii
8,834 Expert 8TB
@onyris
The Form's Current() Event is the right location. Can't understand why it is not working, I've had no problems on this end.
May 22 '09 #19
onyris
42
The Form's Current() Event is the right location. Can't understand why it is not working, I've had no problems on this end.
Had a look again over the names and the code , everything is ok .
Why is it not working?
May 22 '09 #20
onyris
42
right , i have changed a bit , and on the List49 click event i have added this code:
Expand|Select|Wrap|Line Numbers
  1. Me![Label37].Caption = Me![List49].ListIndex + 1
It is working now.
May 22 '09 #21
NeoPa
32,556 Expert Mod 16PB
Onyris,

How about you put a breakpoint on line #2 and debug (Debugging in VBA) it to find out what's going wrong where. Does this sound like something you'd be interested in?
May 22 '09 #22
ADezii
8,834 Expert 8TB
@onyris
Wasn't that indicated in Post #12?
May 22 '09 #23

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
1
by: Kim | last post by:
How can I display "No data found" in the repeater if there are no records found after selecting an item from a dropdown list. Another question is: Can repeater perform paging as in datagrid if...
2
by: rpeacock | last post by:
I am using a repeater to display a list of properties that I am pulling from my database. I am very new to ASP.NET so this is still a bit foreign to me. The repeater is working great for my...
1
by: Ky_fanatic | last post by:
I am working on an application which returns data from multiple databases. The user enters a pallet ticket and it goes out to the multiple db's and returns data which meets the criteria. My...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
0
by: hnpatel | last post by:
Hi.... How to set perticular number of records to display on one page of datareport in vb6.0? I want to display 10 records on one page of datareport. Yes i want to display 5 or 10 records per...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
1
by: sanchezl | last post by:
Hi, I am developing a program in visual basic that extracts info from an access database. So far I know how to add records, make a query and count the number of records that that query gives, but...
2
by: KusoYumi | last post by:
Hi everyone, I have met a problem here regarding the display table. Let me explain my problem 1st. Assume that I want to display a list of data in a table, each page contains 10 records. So when...
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: 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?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.