CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 1999
    Posts
    30

    CRecordSet -->Sort

    Hi all,
    How do I get the data out of my Access-Database into my flexgrid, sorted on one of the recordfields, chosen by me?
    I can get the data into my flexgrid, but only sorted on the ID-number.
    m_...Set.SetCurrentIndex(recordfieldvariable)


    gives no error, but a Debug Assertion Failure.
    Thanx.

    Student Flanders Language Valley
    Programmer

  2. #2
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    Re: CRecordSet -->Sort

    From the on-line help for DAO:

    Records returned from a table-type recordset can be ordered only by the indexes defined for the underlying tabledef. To sort records in some other order, you can open a dynaset-type or snapshot-type recordset using an SQL ORDER BY clause stored in CDaoRecordset::m_strSort.



  3. #3
    Join Date
    Jul 1999
    Posts
    30

    Re: CRecordSet -->Sort

    Where can I get more info concerning this subject?

    Student Flanders Language Valley
    Programmer

  4. #4
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    Re: CRecordSet -->Sort

    You are not really using CRecordSet are you? SetCurrentIndex is a method of CDaoRecordSet.

    Anyway, all you need to do is set up your m_strSort variable before you do an Open() or Requery() for your recordset any the sort should take place. On-line help exists for CDaoRecordSet::m_strSort.

    Here is an example:

    pConditionsSet->m_strSort = "[ConditionSetID], [Logic]DESC, [FieldID]";

    This sorts my recordset in ascending ConditionSetID, descending Logic and ascending FieldID.

    After setting the m_strSort variable make your call to Open() or Requery().

    Hope this helps.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured