Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Sort Cardbox database using external program"

Sort Cardbox database using external program

Current user: [none]
Register / Log In · Help

Posted By Post

Mary Doyle

12-Jun-2015 16:58

Hi folks,

I have been away from any detailed programming of Cardbox for quite a while now and the brain may have slowed down! If I plug away I can probably come up with the solution, but if anyone can answer my problem without too much effort I would appreciate it.

I am writing a VBS Script to open a Cardbox database, sort the database and get data from the last record in the sorted database.
This is what I have tried:
Database opened:

Set recsFileOpened = win.Database.AllRecords
win.SetSequence "*+dc+tc",cbxSequenceRefresh

n = recsFileOpened.Count
Set recLast = recsFileOpened(n)
MsgBox recLast.Fields("na")

Result = Content of Fields("na") but not for the record that should be last in the sequence. The record data that is returned, which after sorting should be the last record in the sort, is incorrect. Sorted it should be last in the sequence. Unsorted it would be Record 6 or 10.

Regard to all.

Mary

bert

12-Jun-2015 17:50

Hi Mary,
Struggled also with sequences in macros.
 
Set recsFileOpened = win.Database.AllRecords :
You make a records object which you cannot sort. Only Window objects you can sort.
I solved it by opening a invisible window of Cardbox and sort that window.
B.e:
    Set cbx=CreateObject("Cardbox.Application")
    cbx.visible = False
    set cbw = cbx.windows
    cbw.OpenFile(Database)
    cbx.ActiveWindow.SetSequence("+FIELD"), cbxSequenceRefresh

    Msgbox cbx.ActiveWindow.Records(cbx.ActiveWindow.Records.count).Fields("FIELD")

Regards
Bert

Mary Doyle

13-Jun-2015 09:00

Hi Bert,
Thank you very much - as always. I had worked out everything else I needed, slowly at first, and then as the brain got back into programming mode, increasingly quickly. But this one was eluding me.

All the best.

Mary

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home