I have been working on this all day and cannot find a way to solve it, although it seems it should be easy.For historical reasons I would like to use my own unique ID's for a filed in one file rather than AutoID's.The problem is that I can't seem to perform any operations on a file while it is in use in an edit window although I experimented with HSavePosition/HRestorePosition unsuccessfully.

So... i created a LOCAL Procedure and used an aliasPROCEDURE New_Comp_ID()sID is stringdsCompAlias is Data SourceIF HAlias(RBL_COMP,dsCompAlias) THEN sID = Upper(Left(EDT_CompNAME,3)) sExt is string i is int IF HReadSeek(dsCompAlias,"COMP_ID",sID) THEN // BUT THIS LINE DOESN'T WORK! WHILE dsCompAlias.COMP_ID [= sID HReadNext() END HReadPrevious() sExt = Right(dsCompAlias.COMP_ID,3) i = Val(sExt) +1 sID = sID +NumToString(i, "03d") ELSE sID += "001" ENDEND

RESULT sID

I have probably been working on this too long and I need some help. Surely someone else has dealt with this problem!

The problem is that I can't seem to perform any operations on a filewhile it is in use in an edit window although I experimented with

I agree, it is a problem, and I don't see why you would have this problem, except of course if you are locking the record or file by code when entering the window. No automatic mechanism will prevent you from creating or modifying a record from inside a window.

So... i created a LOCAL Procedure and used an aliasPROCEDURE New_Comp_ID()sID is stringdsCompAlias is Data SourceIF HAlias(RBL_COMP,dsCompAlias) THEN sID = Upper(Left(EDT_CompNAME,3)) sExt is string i is int IF HReadSeek(dsCompAlias,"COMP_ID",sID) THEN // BUT THIS LINEDOESN'T WORK!

Halias is not enough. It is just defining a NAME for a file. You then have to link that name to your file connection. This is described in the help.

It works as expected unless I uncomment RBL_COMP.COMP_ID = New_Comp_ID() and then I get totally unexpected values in the new record (actually the fields for the 1st record in the file.)Strangely enough, when I fixed the New_Comp_ID function according to your instructions everything worked (although I had to open the WAlias example to get the syntax correct because the Help example has its own syntax error).As usual, it is a case of "Beginner mistakes produce unexpected consequences' but I'm starting to wonder how long it will take to advance beyond Beginner.Thanks Fabrice - once again you are my saviour!Garry