Subject | Re: [IBO] Need help with IBOQuery / IBODatabase |
---|---|
Author | Helen Borrie (TeamIBO) |
Post date | 2002-08-14T03:04:16Z |
At 01:04 AM 14-08-02 +0000, you wrote:
A few suggestions, then...
Perhaps you would like to alter your button2click procedure and your setup
a little so that you don't lose things from the context unnecessarily...
First, at design-time, give QryPersonEdit a persistent SQL property, as
follows:
SELECT * FROM PERSON
WHERE personid = :personid;
Set the RequestLive property to true in the IDE.
Set the KeyLinks property to PersonID in the IDE.
procedure TFrmDoctorEdit.Button2Click(Sender: TObject);
begin
with QryPersonEdit do
begin
if Active then Close;
if DatabaseName <> MyMainForm.IBODatabase1 then
DatabaseName := MyMainForm.IBODatabase1;
if not Prepared then Prepare;
Params[0] := QryPersonListPerson_ID.AsInteger; // more efficient
Open;
if IsEmpty then
begin
Showmessage('There is no corresponding Person record');
(* Just for testing purposes. Handle this situation in an appropriate
way *)
else
Edit;
end;
end;
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com
>I've just converted a very large application using D6 from BDE toPaul,
>IBO (Interbase 6). After following ALL of the steps in the
>BDEtoIBO conversion help file, I ran into a problem.
>
>The application is an MDI application. On the main MDI form I've
>placed an IBODatabase. On a MDI child form I've placed I've
>IBOQuerys, Datasources & IBOStoredProc. The IBOQuerys have their
>database name linked to the IBODatabase on the main MDI form.
>
>On the MDI child form I've opened up a query in a grid that shows
>several records. So far so good!
>
>I have another query on the MDI child form that is opened when you
>press a button. The query takes a parameter 'Person_ID' from the
>first query and opens that record for editing.
>
>procedure TFrmDoctorEdit.Button2Click(Sender: TObject);
>begin
> with QryPersonEdit do
> begin
> Close;
> SQL.Clear;
> SQL.Add('Select * from person');
> SQL.Add('where person_id = :person_id');
> Params.ParamValues['Person_ID'] :=
>QryPersonListPerson_ID.AsInteger;
> RequestLive := true;
> Open;
> Edit;
> end;
>end;
>
>The first time that it opens, it works fine. But if you select
>another record from the first query it still opens the first record.
>
>I've checked the Person_ID and each time it is changing but the
>record returned by the query is always the first record.
>
>Any suggestions would be great!
A few suggestions, then...
Perhaps you would like to alter your button2click procedure and your setup
a little so that you don't lose things from the context unnecessarily...
First, at design-time, give QryPersonEdit a persistent SQL property, as
follows:
SELECT * FROM PERSON
WHERE personid = :personid;
Set the RequestLive property to true in the IDE.
Set the KeyLinks property to PersonID in the IDE.
procedure TFrmDoctorEdit.Button2Click(Sender: TObject);
begin
with QryPersonEdit do
begin
if Active then Close;
if DatabaseName <> MyMainForm.IBODatabase1 then
DatabaseName := MyMainForm.IBODatabase1;
if not Prepared then Prepare;
Params[0] := QryPersonListPerson_ID.AsInteger; // more efficient
Open;
if IsEmpty then
begin
Showmessage('There is no corresponding Person record');
(* Just for testing purposes. Handle this situation in an appropriate
way *)
else
Edit;
end;
end;
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com