473,547 Members | 2,532 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.RecordsetClo ne
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 6291
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.RecordsetClo ne
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
2683
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 = Forms("frmMaster").RecordsetClone 'set an instance of form master recordset clone
3
13937
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 field in the subform default its value so that the next record created uses the value from the box on the main form. So far so good - works fine. ...
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 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...
3
2593
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 to the recordsetclone bookmark. The first form is already open and so is just positioned to the desired record. The second and subsequent forms...
3
2449
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) MySQL = "SELECT Sum(*) AS Expr1 FROM Forms!Form1!Child0.Form.RecordsetClone;"
22
4993
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 calling up another form or report that uses some of the same data. We came up with a work around that saves the current record's ID, does a
3
6177
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 = -1:" DoCmd.RunSQL MySQL Note: in the above example MyField is the Control Source of a Textbox in
10
5755
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 have installed the latest updates to Access and Jet I have checked the references and they are fine I have disabled the 'Sandbox' mode
2
1951
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, 'NotInList' (for customer not in table) and AfterUpdate event which (uses RecordsetClone by customeriD. The Recordsetclone event allows for the other...
0
7437
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7703
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. ...
0
7797
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...
0
6032
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
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...
0
5081
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1050
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
748
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...

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.