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

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(Cancel As Integer)

Me.OrderBy = ""
Me.OrderByOn = True

DoCmd.ShowAllRecords

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 3860
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.Caption

Select Case str
Case "Sort Ascending"
DoCmd.GoToControl "AccNo"
DoCmd.RunCommand acCmdSortAscending
DoCmd.Requery
Me.lbl_AccNo.Caption = "Sort Descending"
Case "Sort Descending"
DoCmd.GoToControl "AccNo"
DoCmd.RunCommand acCmdSortDescending
DoCmd.Requery
Me.lbl_AccNo.Caption = "Show All"
Case "Show All"
Me.OrderByOn = False
DoCmd.RunCommand acCmdRemoveFilterSort
Me.Requery
Me.lbl_AccNo.Caption = "Sort Ascending"
End Select
End Sub

--
Reggie

----------
"Aravind" <so**********@hotmail.com> wrote in message
news:61**************************@posting.google.c om...
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(Cancel As Integer)

Me.OrderBy = ""
Me.OrderByOn = True

DoCmd.ShowAllRecords

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
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...
2
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
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...
6
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...
2
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.", ...
12
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...
49
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...
15
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...
3
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.