Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Visual Foxpro equivalent of Ditto!
Message
From
04/01/2001 15:40:20
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
04/01/2001 15:24:18
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00459224
Message ID:
00459530
Views:
23
>>I have a database that has a lot of repetitive data in fields, though nothing that could be set as a default. I am thinking about adding some features to enhance data entry. Is there anyway to have a keystroke that repeats the value from the last record's field value?
>
>I did this by setting keypreview = .T. in my base class for forms, and adding code to the keypress event of the form class to trap ctrl-D (for Ditto!) to call the Ditto method I added to the form class. Then you can override the ditto method for differen data entry forms to be useful to that particular situation. The basic way I did this was to use SCATTER memvar, and then append a record, filling in the certain fields I wanted, since they were not all supposed to be carried forward. (for example you would need to watch out for your primary key!) I also carried it a bit further, by filling in certain child tables also.

Another way to do this would to Scatter ...name thisform.SaveObj or something like that somewhere in the beginning of the AddNew method (before you actually append blank), and then on Ctrl+D you should simply set
ThisForm.ActiveObject.value=
eval('thisform.SaveObj.'+justext(ThisForm.ActiveObject.controlsource))
This could, of course, be improved in many ways, like setting the automatic ditto per control on/off, having the Ctrl+D switch between the blank and last value (i.e. revert to blank or copy last). It would actually require some checking if you really have an .ActiveObject which is not .null. when this fires, then checking whether it has a controlsource which has a corresponding value in ThisForm.SaveObj, but it wouldn't be more than a dozen lines all together.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform