473,480 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sorting RecordsetClone?

Hi all,

I have a function I use to sort the recordset behind a form on designated
fields of the form (see code below). I pass the field name, and trigger this
function with the click of the field heading. However I'm using filters at
different times on the underlying form recordset, but want the functionality
of being able to sort the resulting recordset using my function.

I don't want to have to pass the filter to the fuinction if I can avoid it.
So im looking for a way to sort the recordsetclone.Ive tried the
recordset.sort property, but can't get it to work. Is there a way to do
this, is there a better approach.

Recordset --------->apply filter ------------->Sort result on various
fields.

-------------------------------------------------------
Function rstSort(sField As String)
Dim sortSql As String
Dim sOrder As String
Dim rs As Recordset
Set rs = Me.RecordsetClone
Dim sortString As String

If sortFlag Then
sortFlag = False
sOrder = ""
Else
sortFlag = True
sOrder = " DESC "
End If
rs.Sort = sField & sOrder

Set rs = Nothing
End Function
-------------------------------------------

Gerry Abbott

Nov 12 '05 #1
1 6276
Gerry Abbott wrote:
Hi all,

I have a function I use to sort the recordset behind a form on designated
fields of the form (see code below). I pass the field name, and trigger this
function with the click of the field heading. However I'm using filters at
different times on the underlying form recordset, but want the functionality
of being able to sort the resulting recordset using my function.

I don't want to have to pass the filter to the fuinction if I can avoid it.
So im looking for a way to sort the recordsetclone.Ive tried the
recordset.sort property, but can't get it to work. Is there a way to do
this, is there a better approach.

Recordset --------->apply filter ------------->Sort result on various
fields.

-------------------------------------------------------
Function rstSort(sField As String)
Dim sortSql As String
Dim sOrder As String
Dim rs As Recordset
Set rs = Me.RecordsetClone
Dim sortString As String

If sortFlag Then
sortFlag = False
sOrder = ""
Else
sortFlag = True
sOrder = " DESC "
End If
rs.Sort = sField & sOrder

Set rs = Nothing
End Function
-------------------------------------------

Gerry Abbott


I would use OrderBy and OrderByOn. Ex:
Me.OrderBy = sField & sOrder
Me.OrderBYOn = True

Nov 12 '05 #2

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

Similar topics

13
2668
by: Seth Spearman | last post by:
Hey guys, I have the following code: '****************************************************** If Not Me.NewRecord Then Dim rs As DAO.Recordset Dim strBookmark As String Set rs =...
3
13904
by: Anthony Kroes | last post by:
I have a subform on a form and they are not linked. On the main form is a text box where the user types in a number. When that number changes, I have some code to make the corresponding text...
1
356
by: Gerry Abbott | last post by:
Hi all, I have a function I use to sort the recordset behind a form on designated fields of the form (see code below). I pass the field name, and trigger this function with the click of the...
3
2588
by: Ian Bailey | last post by:
I have developed a routine that opens a number of forms with each form being positioned on a particular record. I am using the Recordsetclone to find the record and then setting the form bookmark...
3
2445
by: GGerard | last post by:
Hello I am trying to refer in code to the RecordsetClone of a subform datasheet but I'm getting syntax errors. This is what I am writing: Set MyDB = DBEngine.Workspaces(0).Databases(0)...
22
4988
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
3
6155
by: G Gerard | last post by:
Hello Can I write an SQL statement in code using a RecordSetClone of an open form? something like: MySQL = "UPDATE Me!Child0.Form.RecordSetClone SET Me!Child0.Form.RecordSetClone.MyField =...
10
5751
by: d.francis | last post by:
I have converted an Access 97 database to Access 2003 The following code now fails and returns Run-time error '3420' Dim rst as DAO.recordset Set rst = Forms!frm1!frm2.Form.RecordsetClone I...
2
1945
imrosie
by: imrosie | last post by:
Hello, I have a search form that uses a row query to locate a customer by customerID and first & last names, so it's an unbound control. I also have two events associated with this control,...
0
7055
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
6920
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
7059
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,...
1
6758
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
7010
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...
0
5362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4499
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.