Sergey,
I have no spaces in the path. In fact, if I set m.lcIDXName = "c:\_Temp" it still causes the error.
Interestingly enough, if I use use SET INDEX TO... I can set the fullpath to the IDX file and not cause the error. The bad news is that my grid does not switch it's ascending/descending order when I SET ORDER TO...
So to make this work for me, I need to set m.lcIDXName = "somevalidfilename" and not include the path. I've tried the other commands like SET INDEX TO... then SET ORDER TO... and they all generate the same error if I specify the fullpath to the idx file. Weird.
Mike
>Do you have spaces in the path?
>Shouln't you open index first with ?
>
>SET INDEX TO ...
>
>
>>I have a grid in which I allow the user to click on the column header to set the order ascending or descending. I have a method to create an IDX file on the fly. In it I create a string containing the index command - something like:
>>
>>lcIndexCmd = "INDEX ON UPPER(TRANSFORM(" + JUSTEXT(toHeader.Parent.ControlSource) + ")) TO " + m.lcIDXName + " COMPACT"
>>
>>where toHeader is an object reference to the actual header that got clicked and m.lcIDXName is the name of the IDX file I'm going to create.
>>
>>I then issue a macro like, &lcIndexCmd. to create the IDX file. Next I do another macro command to "SET ORDER TO " + m.lcIDXName
>>
>>If I set m.lcIDXName = "_Temp" and run the code, things work fine. The index is created and the order is set. The issue I'm having is, if I set m.lcIDXName = "c:\SomeFolder\SomeSubfolder\_Temp" the macro to set the order crashes with "Command contains unrecognized phrase/keyword".
>>
>>The only thing that I can see that causes this error is the fact that the index name cannot have a full path and will only take a filename.
>>
>>Can anyone confirm this or anyone experience this?
>>
>>TIA
>>Mike