PC Review


Reply
Thread Tools Rate Thread

ADO Sort Property

 
 
=?Utf-8?B?R3JlZyBIb3J3b29k?=
Guest
Posts: n/a
 
      22nd Jun 2004
I have the following sample code which returns a run-time error 3251.

Private Sub btnMain_Click()
Dim rst1 As Recordset

Set rst1 = New ADODB.Recordset
rst1.CursorType = adOpenKeyset
rst1.LockType = adLockOptimistic
rst1.CursorLocation = adUseServer

rst1.Open "tblMain", CurrentProject.Connection
rst1.Sort = "KEY ASC"

rst1.Close
Set rst1 = Nothing
End Sub

The problem is with the Sort Property applied to the recordset object.

Any help greatly appreicated.

Thanks heaps

Greg
 
Reply With Quote
 
 
 
 
Gerald Stanley
Guest
Posts: n/a
 
      22nd Jun 2004
To enable sorting, the cursor location must be adUseClient.

Even when specifying the recordset cursor location to
adUseClient, you may still have a problem as you are using
the CurrentProject connection object (as its CursorLocation
is adUseServer). If so, you will have to declare a
connection object, set it to CurrentProject.Connection,
then change its CursorLocation to adUseClient.

Hope This Helps
Gerald Stanley MCSD
>-----Original Message-----
>I have the following sample code which returns a run-time

error 3251.
>
>Private Sub btnMain_Click()
> Dim rst1 As Recordset
>
> Set rst1 = New ADODB.Recordset
> rst1.CursorType = adOpenKeyset
> rst1.LockType = adLockOptimistic
> rst1.CursorLocation = adUseServer
>
> rst1.Open "tblMain", CurrentProject.Connection
> rst1.Sort = "KEY ASC"
>
> rst1.Close
> Set rst1 = Nothing
>End Sub
>
>The problem is with the Sort Property applied to the

recordset object.
>
>Any help greatly appreicated.
>
>Thanks heaps
>
>Greg
>.
>

 
Reply With Quote
 
=?Utf-8?B?R3JlZyBIb3J3b29k?=
Guest
Posts: n/a
 
      23rd Jun 2004
Thanks Gerald. What you've suggested makes perfect sense. I'll give it a go.

Ta

"Gerald Stanley" wrote:

> To enable sorting, the cursor location must be adUseClient.
>
> Even when specifying the recordset cursor location to
> adUseClient, you may still have a problem as you are using
> the CurrentProject connection object (as its CursorLocation
> is adUseServer). If so, you will have to declare a
> connection object, set it to CurrentProject.Connection,
> then change its CursorLocation to adUseClient.
>
> Hope This Helps
> Gerald Stanley MCSD
> >-----Original Message-----
> >I have the following sample code which returns a run-time

> error 3251.
> >
> >Private Sub btnMain_Click()
> > Dim rst1 As Recordset
> >
> > Set rst1 = New ADODB.Recordset
> > rst1.CursorType = adOpenKeyset
> > rst1.LockType = adLockOptimistic
> > rst1.CursorLocation = adUseServer
> >
> > rst1.Open "tblMain", CurrentProject.Connection
> > rst1.Sort = "KEY ASC"
> >
> > rst1.Close
> > Set rst1 = Nothing
> >End Sub
> >
> >The problem is with the Sort Property applied to the

> recordset object.
> >
> >Any help greatly appreicated.
> >
> >Thanks heaps
> >
> >Greg
> >.
> >

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple property sort using icompare =?Utf-8?B?U3R1?= Microsoft VB .NET 3 5th Aug 2005 01:45 PM
Property Sheet Missing (sort of) Chris Microsoft Access 3 23rd Jun 2004 04:32 PM
Sort or Orderby Property? Don Microsoft Access VBA Modules 1 14th May 2004 08:26 PM
Query on DataView.Sort Property Denzil Microsoft Dot NET 1 23rd Oct 2003 12:01 AM
Sort names into another worksheet by a property Ron Mello Microsoft Excel Programming 2 30th Sep 2003 01:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 AM.