error building key for index

Visual FoxPro 09.00.0000.5815 for Windows

I have a table with several indexes that are set as unique.
These indexes have been in place for several years.
Just recently when issuing an append blank I get the error  <error building key for index  workdate.
The index definition is: workcode + dtoc(invodate) - workcode is C(17) and invodate is D.
The is a flock() placed on the file just prior to the append blank.
If I open the same table in a vfp session I can append blank all day.
Not sure where to go next with this issue.
Need to resolve a.s.a.p..
I have done several selects to weed out any invalid dates etc.
Tried the same code on different workstations.
But still the problem remains.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

"in a vfp session I can append blank all day"

So you are telling us that within the compiled application you are getting the error message but when in the VFP development mode, you get NO error?

Have you tried running the application's forms, prg's, etc. from within the development mode utilizing the TRACE window so that at the precise point in the code where the error is generated, you can examine the variety of other, possibly associated, settings?

On a different note - you might want to consider changing the DTOC() portion of the index expression to DTOS().   They both would work, but DTOS() orders things (as seen visually) in a more logical manner than does DTOC()

Good Luck


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hmm, haven't seen this error yet... and the help description does not fit to your data.

You should check the SET CENTURY setting in your app as the first step.

Then I would recommend to change the key expression to:

PADR(workcode + dtoc(invodate), 27)
or even to
PADR(workcode + dtoc(invodate,1), 25)
Depends how are you using this index.  The PADR() should not be necessary in the last expression but who knows what is happening...

The dtoc() function does not return results suitable for indexing - it depends on SET CENTURY and SET DATE settings at least. SET CENTURY could be the reason of above error but I am not sure.

DTOC(invodate,1) returns 8 characters in given format which is not dependent on the environment settings.

Of course, if you are using above index for records searching then changing the key expression would mean to change your code and you have to decide if this change is suitable now.

Another question would be why UNIQUE indexes? If you mean the classic old unique index created by
INDEX ON workcode + dtoc(invodate) TAG workdate UNIQUE
then it has limited usage in FoxPro application but you probably know it.

kpi_itAuthor Commented:
the switching of dtoc() to dtos() did the trick.
Had thought of it earlier, but didn't think that something that has worked for years.
And has worked the past two years with VFP 9 just would suddenly just stop is weird.
I am glad that the DTOS() did the trick for you.

Just make sure that if you are doing any SEEK's within your application that the expression that you use, also makes use of the DTOS() instead of DTOC() so that your SEEK can actually find what you want.

Good Luck

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.