The program works on my system in VFP7.
I wonder if it is because you use a one-letter variable ("d"). It's not good practice to do so, since the letters "a" through "j" were reserved in early xBase products to refer to the (maximum then available) 10 work areas. Your variable names should always be at least 2 characters; using a scope and type prefix (e.g. lcString, ldDate, etc.) ensures this nicely.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up