In Access there is a property you can set to say that that field is a required field so the user must enter data into that field. Is there a similar thing in fox pro.
Nope, mostly you handle this with record or field validations, that the programmer writes himself/herself.
Most frameworks use a so called business object, that sets the rules for data to be stored (obligatory fields, restrictions on values etc.).
The best way to validate if data has been entered is to notify the user that data has to be entered when the user leaves the control and/or notify the user when he/she tries to save the data (and can of course only save data when required data has been entered).
I have also seen Software packages that color their controls as beeing obligatory and use the forementioned validations.
but as always when try to write code it does not work right
See Below
IF thisform.org_scontact1.value = Null
nAnswer=MessageBox('you have not filled in Account Code You must fill this in before you can continue', 16)
If nAnswer=1
RETURN
EndIF
EndIF
I put this in the save button so as they tried to leave the form it would not let them but it shows them the message regardless of if data is entered into the field or not.
HI,
In your save cmethod.. that is in the click event of your save button.. you have to put the code...
IF EMPTY(ThisForm.myTxtBox.Value)
=MESSAGEBOX("MyTextBox shall not be Blank.",0+16, ;
"Data Entry Error"
ThisForm.MyTextBox.SetFocus
RETURN .F.
ELSE
DODEFAULT()
ENDIF
** In the above method, irrespective of user passing thru the textbox (If the text box is passed thru only, valid event of that gets fired), the validity is checked. Also it is easy to handle all such form level controls in one place, as to thier validity.
Best of luck
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK
Be aware that your user can also close the form by clicking the 'X' in the top right conrner of your form.
Let's say, you want to give your user the option to Save or Cancel, it is better to make a Save method on your form than in the click event of your save button (actually this is the first rule I learned doing a VFP course some years ago, never put too much code in the click event of a command button... ;-) ).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.