473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ 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 6285
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
2678
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
13921
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
2592
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
2448
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
4989
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
6162
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
5754
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
1947
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
7264
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
7166
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
7543
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
5689
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,...
1
5094
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...
0
4749
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
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
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 ...
0
459
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...

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.