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
22 4581 @onyris
You can use the CurrentRecord Property of a Form to identify the Current Record in the Recordset being viewed, as in: - Private Sub Form_Current()
-
Me![lblRecordNumber].Caption = "Record Number " & Me.CurrentRecord
-
End Sub
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.
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 .
@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.
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.
@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.
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.
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. - if List49.Selected =null
-
Me![Label37].Caption = Me.CurrentRecord
-
else
-
Me![Label37].Caption = List49.Selected
@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.
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 : - Private Sub Form_Current()
-
Me![Label37].Caption = Me.CurrentRecord
-
-
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 - Private Sub Form_Current()
-
if ( nothing selected in the listbox)
-
Me![Label37].Caption = Me.CurrentRecord
-
else( get the index number of the selected record and display it )
-
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.
@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: - 'A ListIndex of -1 indicates that 'No Item was Selected'
-
If Me![List49].ListIndex = -1 Then
-
Me![Label37].Caption = Me.CurrentRecord
-
Else
-
'ListIndex Property is Zero based, so add 1 if necessary
-
Me![Label37].Caption = Me![List49].ListIndex + 1
-
End If
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?
@onyris
Is your List Box named List49?
Yes it is i've checked again.
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. - Private Sub Form_Current()
-
If Me![List49].ListIndex = -1 Then
-
Me![Label37].Caption = Me.CurrentRecord
-
Else
-
Me![Label37].Caption = Me![List49].ListIndex + 1
-
End If
-
End Sub
Anything wrong with the code?
@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?
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()?
@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.
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?
right , i have changed a bit , and on the List49 click event i have added this code: - Me![Label37].Caption = Me![List49].ListIndex + 1
It is working now.
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?
@onyris
Wasn't that indicated in Post #12?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
| |