Board index » delphi » Bookmark help

Bookmark help

I am using a form tht has a DBGrid. I would like to mark a record in
the Grid and click a button that brings up another form which is made
up of DBEdit boxes. How can I get the 2nd form to read the marked
record of the grid form? I've tried to bookmark the record in the grid
form but haven't been able to get it to carryover the the box form.

Thanks in advance.

Jim
Js...@inil.com

 

Re:Bookmark help


Hello,
  If the 2nd form is just a more detailed description of the record in
the DBGrid, then you are looking at a classic Master/Detail
relationship.  

One way to do this is use the database expert and create the
master/detail on one form.  

If you are using Delphi 1.0, simply move the details onto the other
form and back reference your DataSource to your original form.  You
will need to include both forms in each form's USES.

In Delphi 2.0, it's easier because you can just make a Data Module and
reference the details and master from the Data Module data source.

For more information check out the MasterSource and MasterDetail
properties of your TTable.

I hope I got this right, and I hope this helps.

Jeff

Quote
js...@inil.com wrote:
>I am using a form tht has a DBGrid. I would like to mark a record in
>the Grid and click a button that brings up another form which is made
>up of DBEdit boxes. How can I get the 2nd form to read the marked
>record of the grid form? I've tried to bookmark the record in the grid
>form but haven't been able to get it to carryover the the box form.
>Thanks in advance.
>Jim
>Js...@inil.com

Re:Bookmark help


Quote
js...@inil.com wrote:

"I am using a form tht has a DBGrid. I would like to mark a record in
"the Grid and click a button that brings up another form which is made
"up of DBEdit boxes. How can I get the 2nd form to read the marked
"record of the grid form? I've tried to bookmark the record in the grid
"form but haven't been able to get it to carryover the the box form.

Just refer to the datasource component on the first form. It depends
on the version of Delphi you are using:

Delphi 1:
- drop DBEdits on Form2;
- just *type in* (as you will not see them) the proper fieldnames in
the DataField property of those DBEdits;
- attach an OnCreate event-handler to Form2:
        procedure TForm2.FormCreate(Sender: TObject);
        begin
                DBEdit1.DataSource := Form1.DataSource1;
                DBEdit2.DataSource := Form1.DataSource1;
                {etc...: you might want to build that in a while-loop}
        end;
- add a "uses UnitOfForm1" to the *implementation* part of Form2;
- add a "uses UnitOfForm2" to the *implementation* part of Form1;
- add an event-handler for the button:
        procedure TForm1.Button1Click(Sender: TObject);
        begin
                Form2.Show;
        end;
That's all: synchronization is automatic as you will see after the
first push, then selecting whatever row from your DBGrid (make two
small forms so you can see them both on your screen).

Delphi 2:
even less to do, as you will see Form1's datasource(s) in the
dropdown-list and subsequently, after selecting one, the available
fields in the dropdown-list for that property.

Good luck!

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Other Threads