473,394 Members | 1,889 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,394 software developers and data experts.

Work with 2 sort orders simultaneously

675 512MB
I have a form, fMain, that displays a single record from a table tMovies. This table has several fields, amongst them Key (PK), Title, DateSeen

Also on the form are 2 listboxes and 5 command buttons:
lbxAlphabet.RowSource = "*","#","A","B","C",..."Z"
lbxTitles.RowSource = "SELECT Key, Title FROM tMovies WHERE ... ORDER BY Title"

cmdCreateFilter: creates the string strWHERE for use in lbxTitles.RowSource from input on a modal form and from lbxAlphabet
cmdFirstRec: moves to the first record shown in lbxTitles
cmdPriorRec: moves to the previous record from the highlighted (selected) row in lbxTitles
cmdNextRec: moves to the next record from the highlighted (selected) row in lbxTitles
cmdLasttRec: moves to the last record shown in lbxTitles

cmdXxxxRec (any of the above navigation buttons) changes the highlighted (selected) row of lbxTitles as well as changing the form data record.

The form data is displayed by fMain.Filter = "Key=" & lbxTitles.Column(0)

Assume for this question that lbxTitles has at least 1 row. If it doesn't, then cmdXxxxRec controls are set to .Enabled=False and cannot be used

All of the above works!

My question: On occasion I want the comXxxxRec buttons to use the DateSeen, sorted ASCending. So after filtering, say for all movies seen in 2008, lbxTitles would display "3:10 to Yuma" as the first row, and "Zodiac Killer" as the last row. I have selected "Men of Honor", about in the middle of the list, but seen 3 Mar08.
If I click cmdFirstRec, "Passenger 57" should be highlighted in lbxTitles, and the form should display that record, because I saw it 2 Jan08. cmdNextRec would highlight and display "The Flight of the Phoenix" seen 3 Jan08. lbxTitles would remain in alphabetic order.

How do I do this?
Jun 15 '09 #1
6 1621
FishVal
2,653 Expert 2GB
Hello, OldBirdMan.
  • You may open an additional recordset ordered by [DateSeen] - listbox choice moves cursor to a record with a given [Key] value, navigation buttons move cursor recordwise.
  • The recordset mentioned above could be the form's recordset. Thus your ListBox is ordered by [Title] and form is ordered by [DateSeen].

Regards,
Fish.
Jun 15 '09 #2
OldBirdman
675 512MB
Thanks Fish -

You may open an additional recordset ordered by [DateSeen] - listbox choice moves cursor to a record with a given [Key] value, navigation buttons move cursor recordwise.
I thought of this, and it works for displaying the data, but to highlight the Title in lbxTitles I have to loop through the listbox searching for the key. In the example given, there are only a few thousand rows at most, but even here Access does not populate the entire listbox until an attempt is made to access rows not populated. I'm not sure how Access keeps track, but it runs slower than might be expected.
My program for keeping track of birds has 300K+ records in one table, and this solution seems somewhat awkward. I will use this logic in at least 3 of my projects, Movies is the simplist and so used in my original post.


The recordset mentioned above could be the form's recordset. Thus your ListBox is ordered by [Title] and form is ordered by [DateSeen].
This has the same problems as the other idea, I cannot know the row of the listbox without a loop to search for the key. Although not stated in my original post, I have one case where I would want 3 sort orders, and this method is not expandable.

I am really hoping to keep the highlighted current record in lbxTitles if practical.
Jun 15 '09 #3
NeoPa
32,556 Expert Mod 16PB
What springs to mind is that any sorting should always be applied to both the form and the ListBox simultaneously. .Requery should also be applied where necessary. Otherwise the record sets may get out of sequence and thus cause problems similar to those you're experiencing.
Jun 15 '09 #4
FishVal
2,653 Expert 2GB
Well.

If ListBox.BoundColumn=1 then does it help to use ListBox.Value property to get set highlighted row?
Jun 15 '09 #5
OldBirdman
675 512MB
Please forgive my slow response to the last suggestion. I needed to look at many projects to see if this would work.

As it turns out, all of these listboxes had ListBox.BoundColumn = 0 which made things quite simple. ListBox = ListBox + 1 highlighted the next row and .Column(0) produced the Key for the record. FishVal's suggestion of using .BoundColumn = 1 does exactly what I need. More work to implement, but that is to be expected if I want more functionality.

Thank you!
Jun 17 '09 #6
NeoPa
32,556 Expert Mod 16PB
Pleased to hear it OB. Thanks for the update :)
Jun 17 '09 #7

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

Similar topics

0
by: David | last post by:
Hi, I have a MySQL database and in the front-end software I am using to Run MySQL, I have created a query on the tables which runs in the front-end, similar to the MS Access query grid. I now...
2
by: BjoernJackschina | last post by:
Hello, I just look for a capability to sort several words in view of alphabet. An example: stop is 'opst' reach is 'aechr' This should read in a new file so that I can look for same letter...
5
by: Dr. Ann Huxtable | last post by:
Hello All, I am reading a CSV (comma seperated value) file into a 2D array. I want to be able to sort multiple columns (ala Excel), so I know for starters, I cant be using the array, I need...
19
by: David | last post by:
Hi all, A while back I asked how to sort an array of strings which would have numerals and I wanted to put them in sequential numerical order. For example: myArray = "file1"; myArray =...
6
by: Les Juby | last post by:
I need to extract records from a database subject to conditions and only thereafter give the users the choice of which fields to sort the results on. In this situation I can't write back to a...
48
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) *...
10
by: kruzin24 | last post by:
I have a worksheet that I run a list of macros from, and a sheet called Orders.xls that is edited by the worksheet. It has 4 columns, and a maximum of 3000 rows. I recorded a macro to sort the...
8
by: Mark12345 | last post by:
Hi folks, thanks for looking. I have a database that takes down order details. Each customer has there own priceid in the price table. the errors that I get say enter parameter value for:...
3
by: printline | last post by:
Hello All I have a table with some information in the rows on orders placed by my customers. Each column in the table represents some data on the product in the row. What i want to do is make...
5
kcdoell
by: kcdoell | last post by:
I have a form that I want to change the way the subform (continuous) is displaying the info (the sort order). In another words, I want to give the user the ability to see the same information in...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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...
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
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...
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...

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.