473,782 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't sort after filtering

Hi folks.

My form, frmHistory, has a combo box, cboName, that filters frmHistory
by member's name (using a macro). frmHistory also has a few labels
that I use for sorting the form (using VBA code). The problem is that,
when I filter the form using cboName, I can't sort the filtered form
(the form becomes empty if I try to sort). Here are the coding (I'm
using the sorting code for 1 of the labels). Does anyone know what
went wrong? I'm using Access 97. Thanks

--------------------------------------------------------------------------------
Private Sub Form_Open(Cance l As Integer)

Me.OrderBy = ""
Me.OrderByOn = True

DoCmd.ShowAllRe cords

End Sub
---------------------------------------------------------------------------------------
Private Sub lbl_AccNo_Click ()

Static x
x = x + 1
If x > 2 Then x = 1

Select Case x:
Case 1: Me.OrderBy = "AccNo"
Me.OrderByOn = True
Case 2: Me.OrderBy = "AccNo DESC"
Me.OrderByOn = True
End Select

End Sub
---------------------------------------------------------------------------------------
macro_cboName

Action: OpenForm
Form name: frmHistory
Where Condition: [MemName]=[Forms]![frmHistory].[cboName]

Action: SetValue
Item: [Forms]![frmHistory]![cboName]
Expression: Null
Nov 13 '05 #1
1 3887
There's other ways and this is sort of sloppy but it works. Initially set
the caption of this label to something like "Sort Ascending" (no quotes)

Private Sub lbl_AccNo_Click ()
Dim str As String
str = Me.lbl_AccNo.Ca ption

Select Case str
Case "Sort Ascending"
DoCmd.GoToContr ol "AccNo"
DoCmd.RunComman d acCmdSortAscend ing
DoCmd.Requery
Me.lbl_AccNo.Ca ption = "Sort Descending"
Case "Sort Descending"
DoCmd.GoToContr ol "AccNo"
DoCmd.RunComman d acCmdSortDescen ding
DoCmd.Requery
Me.lbl_AccNo.Ca ption = "Show All"
Case "Show All"
Me.OrderByOn = False
DoCmd.RunComman d acCmdRemoveFilt erSort
Me.Requery
Me.lbl_AccNo.Ca ption = "Sort Ascending"
End Select
End Sub

--
Reggie

----------
"Aravind" <so**********@h otmail.com> wrote in message
news:61******** *************** ***@posting.goo gle.com...
Hi folks.

My form, frmHistory, has a combo box, cboName, that filters frmHistory
by member's name (using a macro). frmHistory also has a few labels
that I use for sorting the form (using VBA code). The problem is that,
when I filter the form using cboName, I can't sort the filtered form
(the form becomes empty if I try to sort). Here are the coding (I'm
using the sorting code for 1 of the labels). Does anyone know what
went wrong? I'm using Access 97. Thanks

-------------------------------------------------------------------------- ------ Private Sub Form_Open(Cance l As Integer)

Me.OrderBy = ""
Me.OrderByOn = True

DoCmd.ShowAllRe cords

End Sub
-------------------------------------------------------------------------- ------------- Private Sub lbl_AccNo_Click ()

Static x
x = x + 1
If x > 2 Then x = 1

Select Case x:
Case 1: Me.OrderBy = "AccNo"
Me.OrderByOn = True
Case 2: Me.OrderBy = "AccNo DESC"
Me.OrderByOn = True
End Select

End Sub
-------------------------------------------------------------------------- ------------- macro_cboName

Action: OpenForm
Form name: frmHistory
Where Condition: [MemName]=[Forms]![frmHistory].[cboName]

Action: SetValue
Item: [Forms]![frmHistory]![cboName]
Expression: Null

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4639
by: Tim Marshall | last post by:
The following is happening in two instances in A2003. The one I s\describe is the easiest one. Theme controls and autocorrupt have been turned off long ago. An unbound main form with a list box (query row source and multi-select turned off) and a datasheet subform. The short cut menu for the datasheet subform includes standard sort ascending and descending and remove filter/sort menu items. The recordsource for the subform datasheet...
2
1819
by: JL | last post by:
Hi all, I want to sort the rows in dataTable and the order of rows is permanent change, is this possible in dataTable? Thanks a lot.
2
5665
by: news reader | last post by:
Hi, Does anoone of you know if there is already a simple application doing something like this. I would enhance / tune the missing features, but would like to avoid to start from scratch or to start from something, that has far too many features and is difficult to setup.
6
3067
by: Chris Zoper | last post by:
Hello, I have a form that shows a lot of records based on a passthrough query to a SQL Server database. I noticed that the Filter and the Sort property of the form do not properly work, often the filter and sorting are not performed. When I base the form on a query on an Access-table everything works just fine, but when I use the passthrough query nothing happens. Does anyone know how to solve this problem?
2
29662
by: tee | last post by:
Hi, How do i sort datagridview programmically, current i have the following code but i keep get the error saying "DataGridView control must be bound to an IBindingList object to be sorted.", What is IBindingList and how would i go about using it. Here are my code private void dataGridView1_ColumnHeaderMouseClick(object sender,
12
3815
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values in my 'onpageload' in the cs file.
49
6119
dima69
by: dima69 | last post by:
Hi all. Here is a problem. I want to sort a form by absolute value. Let's say, if I have a field named "theSum", I'd like to set the form OrderBy property to "Abs()". If I use "Advanced filtering\sorting" from "Records" menu, it works just fine, and OrderBy proprty becomes "Abs()". But when I do the same thing manually or programmatically, it doesn't work. So I cannot figure out what is the trick here and how to make this work.
15
2607
by: Academia | last post by:
I want a string of characters that will sort after all strings of Roman letters. Something that will display using a font like the one this note is written with. Is there such a thing? I tried using a string starting with { because in ASCII it comes after the letters but that sorts before the letters.
3
2844
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one dataset to data in a second dataset, using a common key. I will first describe the problem in words and then I will show my code, which has most of the solution done already. I have built an ASP.NET that queries an Index Server and returns a...
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9942
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.