Adding Record in DBF from VFP9 Form entry

50 Views Asked by At

I have created a Form which will add the student's details in DBF. The DBF field names are stud_fnme, stud_mnme, stud_lnme, stud_dob etc. there are total 30 fields.

I want, once entering the details in the form, the input details to be added to the DBF

  1. Add one blank record in the DBF (append blank)
  2. Replace all the respective fields with entered details.

I am not able to do this.

I have tried by doing this following code

Sele A
Use Stud_mast
Index on Admn_numb Tag adnum

append blank
replace stud_nme with Fname
  • stud_fnme is DBF field name
  • fname is the Form field Name
1

There are 1 best solutions below

0
Cetin Basoz On

That is not the way of doing that (append blank and then replace). Instead, on your form place the controls with controlsources set to corresponding fields. An easy way of doing this:

  • Add your table to dataenvironment.
  • In DataEnvironment, select the fields you want on your form using shift\ctrl click.
  • Drag drop them on to your form. VFP would as to create a grid or separate controls.
  • Choose separate controls.

Now if you append blank, you would be directly editing the fields in table.

For greater control you would want to enable table buffering so you would decide in code to commit or revert the changes.

PS: When you need Append blank and then replace, consider using INSERT INTO - SQL instead.