Board index » delphi » Help needed with a DBGrid -> MultiSelect feature

Help needed with a DBGrid -> MultiSelect feature

How can I use the multiselect feature of a DBGrid to change field
values in the underlying table?

example:

User selects 5 records in a grid to update

I want to jump to each record and change the value in the  
the table to some value by referring to the TBookMarkList component of
the TDBGrid. I tried

for i:=0 to DBGrid1.SelectedRows.Count-1 do
    with MyTable1 do begin
        GotoBookMark(DBGrid1.SelectedRows.Items[i]);
        FieldByName('Type').Value:='FOO'
   end;

but I get an error "Incompatible Types STRING and POINTER. I know WHY
I'm getting the message but I can't find an example of using the
TBookmarkList component to get this resolved...

Anyone got any pointers :)

Bill Artemik

barte...@wakefield.com

Bill
-------------------------------
Programmer/Analyst
Wakefield Engineering, Inc.
barte...@wakefield.com

"There are THREE kinds of people in the world...
     Those that can count and those that can't."

 

Re:Help needed with a DBGrid -> MultiSelect feature


Hi!

Try to use the following  lines.

 for i:=0 to DBGrid1.SelectedRows.count-1 do
         begin
         DataModuleMain.Query.Bookmark := DBGrid1.SelectedRows.Items[i];
         StrPCopy(t,DataModuleMain.Query.FieldByName('PosNr').asString);
         Application.MessageBox(t, 'Meldungsfenster', mb_OKCancel +
mb_DefButton1);
         end;
     end;

Bill Artemik schrieb in Nachricht <357259f6.180962...@news1.newscene.com>...

Quote
>How can I use the multiselect feature of a DBGrid to change field
>values in the underlying table?

>example:

>User selects 5 records in a grid to update

>I want to jump to each record and change the value in the
>the table to some value by referring to the TBookMarkList component of
>the TDBGrid. I tried

>for i:=0 to DBGrid1.SelectedRows.Count-1 do
>    with MyTable1 do begin
> GotoBookMark(DBGrid1.SelectedRows.Items[i]);
> FieldByName('Type').Value:='FOO'
>   end;

>but I get an error "Incompatible Types STRING and POINTER. I know WHY
>I'm getting the message but I can't find an example of using the
>TBookmarkList component to get this resolved...

>Anyone got any pointers :)

>Bill Artemik

>barte...@wakefield.com

>Bill
>-------------------------------
>Programmer/Analyst
>Wakefield Engineering, Inc.
>barte...@wakefield.com

>"There are THREE kinds of people in the world...
>     Those that can count and those that can't."

Other Threads