Subject Re: [IBO] How open a dataset with only a Bookmark record?
Author Marco Menardi
Thanks Helen, but I don't have params in my query.
I have a simple select without WHERE, and the user enters the search
criteria and locates the record(s) he wants.
Now, I want the possibility to open the same form on a specific row,
the same as another (lookup) dataset (i.e. the user is working on
customer's orders, with a lookup dataset on customers table. Then he
selects a row and press F7, then the Customer edit form pops and that
customer data show. So I want to bring the Bookmark of the lookup on
customer table and use it to open the customer editing form).
Would be great having a method like "BookmarkToSearch" that fills the
search criteria with the bookmark values, so I only have to pass a
string (bookmark) to the form.
I'm trying to use a protected method: SetBufferBookmark(bookmark)
I don't know if it's the right direction, but I've got a strange error
(ok, it's not IBO related, but...)
// just to access protected methods
TIB_Protected_BDataset = class(TIB_BDataset);

// this works as expected...
with (FBaseDataSource.DataSet as TIB_BDataset) do

// this raises an "Invalid Class TypeCast"
with (FBaseDataSource.DataSet as TIB_Protected_BDataset) do

D6, SP3.
really s trange, isn't it?

thanks
Marco Menardi

--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> At 11:29 AM 16/03/2003 +0000, you wrote:
> >I have a bookmark for a lookup dataset. I want to use that bookmark
> >for opening another dataset on the same record.
> >I don't want to use something like:
> >with qryCustomer do
> >begin
> > Open;
> > Bookmark := workBookmarkString;
> >end;
> >because this way all the data is requested to the server and THEN the
> >right record is located.
> >I want instead have the behaviour the IBO Search has, i.e. return only
> >the desired record, but I don't know how to make my workBookmarkString
> >being used as a search criteria.
> >In other words, I would like to have something like:
> >with qryCustomer do
> >begin
> > Search;
> > Bookmark := workBookmarkString;
> >..First;
> >end;
> >
> >that does not work.
> >I don't want to fill the other field values for a search, since I need
> >a generic solution and Bookmark produces always an unique key.
> >How can I do?
>
> KeyFields is a TIB_Row containing a TIB_Column object for each of the
> KeyLinks columns of the row in the row buffer. Bookmark saves the
current
> row's KeyFields[n].Value properties as variants cast to strings, in a
> semicolon-separated string, in the SQL column order.
>
> So, if you want to apply the Bookmark values to the parameters of the
> dataset's SQL generically, you could parse the values out an apply
them to
> the Params[n] - but only if your Params were in the same order as
the SQL
> order of the KeyLinks.
>
> Instead of using Bookmark, you could extract KeyFields.FieldName and
> KeyFields.Value out into a stringlist of the format FieldName=Value.
>
> This gives you a way to get and store the key field names and values
> generically, and independently of SQL order; then you can construct a
> generic ParamByName assignment procedure by looping through the
stringlist.
>
> e.g., something along these lines:
>
> procedure MyForm.GetSelectedRow (Dataset: TIB_Query);
> var
> StoredParms: TStringlist;
> ii: integer;
> begin
> if Dataset.IsEmpty then
> Exit;
> StoredParms := TStringlist.Create;
> try
> with Dataset, StoredParms do
> begin
> for ii := 0 to KeyFields.ColumnCount - 1 do
> Add(KeyFields[ii].FieldName + "=" + KeyFields.AsString);
> Close;
> for ii := 0 to Count - 1 do
> ParamByName(Names[ii]).Value := Values[Names[ii]];
> Open;
> end;
> finally
> StoredParms.Free;
> end;
> end;
>
> Helen