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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save selected records from grid to another table

Status
Not open for further replies.

keepfoxing

Programmer
Dec 9, 2015
37
PH
i have a grid with a checkbox column and what i want is
when a user selects as many records from the grid, all records selected will be save to
another table..
tnx
 
The Grid's checkbox is related to a Logical field in the Grid's supporting table/cursor.
With that in mind, when the user clicks to put a check into a checkbox, they are setting that associated field to TRUE (no check = FALSE)

I assume that you have some button to initiate the SELECT Query from the Grid's table/cursor.

With that in mind, you only need to have something like in the Button's Click method:
Code:
SELECT <list_of_desired_fields>;
  FROM <GridsTable>;
  WHERE <Checkbox_field>;
  INTO TABLE <newTableName>

Example:
Code:
SELECT Fld1, Fld2, Fld3;
   FROM MyTable;
   WHERE Chosen;
   INTO TABLE NewTable

What you do with the new table has yet to be discussed.

Good Luck,
JRB-Bldr

 
yeah, it worked..
but how to get that record into an existing table..
should i use loop on it?
 
When the target table (or cursor) already exist, you do an INSERT INTO target SELECT FROM, ie:
Code:
Insert Into target (fld1,fld2,fld3);
SELECT Fld1, Fld2, Fld3;
   FROM Gridcursor;
   WHERE Chosen

The field names don't need to match, even the types may vary, though automatic conversions may fail, eg inserting a char field into a numeric field you will get 0s for any text. Actually the same rules as APPEND apply and you may also know and use [tt]SELECT TARGET[/tt] followed by [tt]APPEND FROM DBF("Gridcursor") FOR CHOSEN[/tt] instead, if the field names match.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top