Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort an ADO form recordset 1

Status
Not open for further replies.

seaport

MIS
Jan 5, 2000
923
US
I got a very strange situation.

I am using Access 2000. I created an ADO recordset, with cursor location on the client side, from a stored procedure (ADO command). Then I set this recordset to be the form recordset of a continuous form. There are several buttons on the form so a user can click on it to sort the form data. The form data is sorted by the following code:

Me.OrderByOn=True
Me.OrderBy=strOrderBy

The form is sorted OK for the first sort. When I tried to sort it the second time, I got an error 2725 - the OLE Server isn't registered.

I got the same error even after I reset the form recordset each time before the sort.

I am not what I did wrong. Any suggestions?

Thanks in advance.

Seaport
 
I tried setting Sort property of the recordset before it is bound to the form, but this did not work. The form data is in the original order always - the order before Sort property is specified. What is strange is that, the cursor of the form recordset seemed to be affected by the sort. For example, if the sort property is specified as "Amount asc", after the form is bound to the recordset, the cursor (record selector) starts at the record with least amount, but that record is not the first record in the form.

Seaport
 
Move the Me.OrderBy= line above the Me.OrderByOn=True line.

John
 
Hi, John,

Thanks so much. Your tip pointed me to the right direction.

Here is the code that works

Me.OrderbyOn=False
Me.OrderBy= strOrder
Me.OrderByOn=True

The line "Me.OrderbyOn=False" is necessary, Otherwise I got the same error.

Could you tell me why I got the error? What is the trick behind "OrderBy" of the form recordset?

Seaport
 
Just a follow-up on this "Order By" issue.

MS Access Visual Basic Help shows that the default value of FilterByOn property is False. My test showed that the default value of this property (when the form is opened) is True, whether the OrderBy property has been set or not.

Seaport
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top