Subject | Re: Query.Locate -with OrderingItems & OrderingLinks |
---|---|
Author | james_027 |
Post date | 2003-11-13T00:47:31Z |
Hi,
I may know one thing, everytime you perform a locate what is the
current selected record? is it the first one?
I may know one thing, everytime you perform a locate what is the
current selected record? is it the first one?
--- In IBObjects@yahoogroups.com, "Michael Horne" <guardian@p...> wrote:
> Hello,
>
> I have run into a problem. I need query.locate to
> position to the first record with a value, even if
> the record ordering has been changed since the query
> was opened. That doesn't happen currently, or I am
> doing something wrong.
>
> If I open query of:
> SELECT NC_ID, NC_Name, NC_REFERENCE
> from NetComIn order by NC_Reference
> perform a
> query.locate(('NC_Reference', 'GARY', []);
> it will position to the first 'GARY'
>
> However if I have a query of:
> SELECT NC_ID, NC_Name, NC_REFERENCE
> from NetComIn
> with the following OrderingLinks
> ByType=NC_name, NC_ID desc; NC_Type desc, NC_ID desc
> ByReference=NC_REFERENCE, NC_ID desc; NC_REFERENCE desc, NC_ID desc
> perform a
> query.locate(('NC_Reference', 'GARY', []);
> it will NOT position to the first 'GARY'
>
> Change the ordering to us the 'ByReference' one and
> do the locate it still doesn't find the first record.
>
> You will find below the code and components I used
> to do this.
>
> I hope you all have some ideals?????
>
> Thanks
> Michael L. Horne
>
> unit fTest;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
> Dialogs, StdCtrls, ExtCtrls, IB_Components, Grids, IB_Grid;
>
> type
> TformTest = class(TForm)
> IB_Query1: TIB_Query;
> IB_Grid1: TIB_Grid;
> IB_DataSource1: TIB_DataSource;
> Panel1: TPanel;
> edLocate: TEdit;
> Button1: TButton;
> btLocateName: TButton;
> btLocateRef: TButton;
> procedure Button1Click(Sender: TObject);
> procedure btLocateNameClick(Sender: TObject);
> procedure btLocateRefClick(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> formTest: TformTest;
>
> implementation
>
> {$R *.dfm}
>
> procedure TformTest.Button1Click(Sender: TObject);
> begin
> ib_Query1.Close;
> ib_Query1.Open;
> end;
>
> procedure TformTest.btLocateNameClick(Sender: TObject);
> begin
> ib_Query1.Locate('NC_Name', edLocate.Text, [lopPartialKey,
> lopFindNearest]);
> end;
>
> procedure TformTest.btLocateRefClick(Sender: TObject);
> begin
> // qyNetComIn.Locate('NC_Reference', 'GARY', [lopPartialKey,
> lopFindNearest]);
> ib_Query1.Locate('NC_Reference', edLocate.Text, []);
> end;
>
> end.
>
>
>
> object formTest: TformTest
> Left = 314
> Top = 480
> Width = 661
> Height = 434
> Caption = 'formTest'
> Color = clBtnFace
> Font.Charset = DEFAULT_CHARSET
> Font.Color = clWindowText
> Font.Height = -11
> Font.Name = 'MS Sans Serif'
> Font.Style = []
> OldCreateOrder = False
> PixelsPerInch = 96
> TextHeight = 13
> object IB_Grid1: TIB_Grid
> Left = 0
> Top = 97
> Width = 653
> Height = 310
> CustomGlyphsSupplied = []
> DataSource = IB_DataSource1
> Align = alClient
> TabOrder = 0
> end
> object Panel1: TPanel
> Left = 0
> Top = 0
> Width = 653
> Height = 97
> Align = alTop
> Caption = 'Panel1'
> TabOrder = 1
> object edLocate: TEdit
> Left = 160
> Top = 8
> Width = 121
> Height = 21
> TabOrder = 0
> Text = 'GARY'
> end
> object Button1: TButton
> Left = 16
> Top = 8
> Width = 75
> Height = 25
> Caption = 'Open File'
> TabOrder = 1
> OnClick = Button1Click
> end
> object btLocateName: TButton
> Left = 16
> Top = 40
> Width = 75
> Height = 25
> Caption = 'Loc Name'
> TabOrder = 2
> OnClick = btLocateNameClick
> end
> object btLocateRef: TButton
> Left = 16
> Top = 64
> Width = 75
> Height = 25
> Caption = 'Loc Ref'
> TabOrder = 3
> OnClick = btLocateRefClick
> end
> end
> object IB_Query1: TIB_Query
> DatabaseName = 'C:\Offroad\IB\ORInventory.gdb'
> FieldsDisplayWidth.Strings = (
> 'NC_REFERENCE=108')
> IB_Connection = formIBData.cnMain
> SQL.Strings = (
> 'select nc_id, nc_name, nc_reference'
> 'from netcomin')
> ColorScheme = False
> MasterSearchFlags = [msfOpenMasterOnOpen,
msfSearchAppliesToMasterOnly]
> OrderingItemNo = 1
> OrderingItems.Strings = (
> 'byname=nc_name, nc_id; nc_name desc, nc_id desc'
> 'byreference=nc_reference, nc_id; nc_reference desc, nc_id desc')
> OrderingLinks.Strings = (
> 'nc_name=1'
> 'nc_reference=2')
> BufferSynchroFlags = []
> FetchWholeRows = True
> Left = 384
> Top = 16
> end
> object IB_DataSource1: TIB_DataSource
> Dataset = IB_Query1
> Left = 304
> Top = 16
> end
> end