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!

How to use a record number. 2

Status
Not open for further replies.

tripp2222

Technical User
Nov 30, 2004
32
US
I understand enter data into a table when data is entered from a form, but I am having difficulty figuring out how to enter information into a field that does not come from a form like a custId. I would think I need to write some code that went something like
IF (a record is added)
INSERT X + 1
ENDIF
I am new to object-oriented programming.
 
Hi Trip2222,

If you want to alter the contents of a field in an existing record:

- Navigate to the record in question, for example using GO, LOCATE, SEEK or whatever.

- Use REPLACE to update the field.

If you want to add a new record, use APPEND BLANK, then use REPLACE to insert the value into a specific field.

In both cases, make sure that the correct table is selected before you start.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-consult.com)
 
You can also use SQL to add or update a record if this is more familiar to you from other languages
Code:
*-- Add
INSERT INTO Customer (cust_id, company) VALUES ("XXX", "YYY")

*-- Update
UPDATE Customer SET Company = "ZZZ" WHERE cust_id = "XXX"

Geoff Franklin
 
I think you are looking for primary key generatoin like an autoincrementing field. Since vfp8 there is a field can be an autoinc field.

And there is an example in the vfp solutions in HOME()+"Samples/Solution/DB/newid.dbc". This DBC has a stored procedure for generating such a number without the autoinc fieldtype.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top