Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Warn to Save record before exiting a Form

Status
Not open for further replies.

aarohivi

Technical User
Mar 23, 2004
5
MT
My company is currently evaluating a program that has been developed in Visual FoxPro (I think ver 8). During the demo of the software we noticed a couple of quirks. Upon asking the person to modify the software to eliminate these quirks, we were told that this is inherent with VFP and could not be eliminated or needed a lot of rework. I found this hard to believe and so started searching this forum to see it anyone else had the same issues. So here we go:

1. All numeric fields display a “,” (comma) for thousand delimiter during Edit and Display. When entering a value in the numeric field you must always enter the “.” (Decimal or full stop) to end the entry otherwise an extra zero is added to the numeric value. E.g. [1,00 .00] becomes [1,000.00]. We were told that the only way to ‘fix’ this would be to eliminate the ‘,’ thousand delimiter. I found it hard to believe that VFP does not allow numeric field to be formatted to displayed with ‘,’ thousand delimeter but when in editing mode it allows you enter the number without the thousand delimiter or save the data accurately. I found this entry in this forum but was not sure if it dealt with numeric fields.
2. In this application, the user opens a form and pulls up an existing record. Imagine the user changes some values in the fields of this form. If the user closes the form without hitting the save button, any edits made are lost. The application does not warn “Do you want to save the changes you have made” or something similar. Again, we were told that the only way to do this was to write code in every form that would take each field value and compare is against the database for that record to determine if it had changed – in other words a lot of extra coding. Again, I was surprised by that comment.

Are there any tips that I can pass on to this programmer regarding the above questions?

Many Thanks
 
1. remove or change the inputmask for the inputfield

2. add a changed propertie to the form
add a line thisform.changed = .T. in the change event of each inputfield
in the queryunload event of the form check for the thisform.changed value
remember to put thisform.changed = .f. in the savefunction

this is just one way i can quickly think of

 
aarohivi,

To put it bluntly: You are right and the developer is wrong. The things you are asking for are both normal things that you would expect in any application. There is nothing in VFP that prevents you having them.

To answer your specific points:

- The behaviour with the comma and decimal point can be overridden by removing the control's input mask when the control first gets focus, and restoring it when editing is complete.

- To deal with unsaved edits, the programmers needs to write some code that loops through all the fields in the buffer, check them against the original values, set a flag if at least one of them has changed, and then issue the prompt. The code would consist of about a dozen lines, and would be completely generic (the same for all forms).

Although the required code is simple in both cases, I suspect the developer's worry is that he will have to place this code in many different parts of the application (the stuff with the input mask would go into each text box, and the test for unsaved edits in every form).

If the developer has used recognised object-oriented techniques, that wouldn't be an issue. If he hasn't, it would take quite a lot of effort to propagate the code throughout the application. But it would be purely mechanical effort -- bsically a lot of cutting and pasting -- rather than any tricky programming.

To sum up, press the programmer to do these changes, both of which are perfectly reasonable. If you come across any further issues, come back here to ask about them.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Mike, you wrote;

- The behaviour with the comma and decimal point can be overridden by removing the control's input mask when the control first gets focus, and restoring it when editing is complete.

Could you elaborate on "restoring" the imput mask (numeric $XXX,XXX,XXX.XX)when textbox has lostfocus?
Thanks
John


 
John,

In the GotFocus of the textbox:

THIS.SaveMask = THIS.Inputmask
THIS.InputMask = ""

In the LostFocus:

THIS.InputMask = THIS.SaveMask

asuming SaveMask is a custom property of the textbox class.

The effect will be to remove all formatting characters (commas, etc) while the control is being edited, while still displaying them at other times.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I have been on both sides of developer/customer issues like you have encountered. And, from that perspective, I might offer some advice.

Due to the in-accurate and/or non-responsive answers you got from the developer about your requests, some Red Flags should be raised. If your requests were extremely exotic, perhaps the developer might be reluctant to introduce them into his product and inform you as such, but to give you in-accurate, side-stepping answers is inexcusable.

You might want to consider purchasing the source code when/if you purchase the VFP product.

In that way you can modify the product to your heart's content. And you will not run the risk of creating a bad vendor/customer relationship by educating him on what he should already know. Plus you will eliminate the possibility of having to hear excuses for the life of the product.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Thanks everyone for your prompt feedback and very valid responses. My next challenge is to convey these responses without offending the person or jeopardizing our relationship with vendor.

Thanks again,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top