Jump to record using TfrxADOQuery at runtime!

Hello everyone,
Using TfrxADOQuery in data page, I try to locate specific record at runtime, here is my attempt:
    with DataSets[0].DataSet do begin    
      RecNo := OtherDataSet.RecNo;//RecNo is readOnly :(
      RangeBegin := rbCurrent;
      RangeEnd := reCount;
      RangeEndCount := 1;      
    end;
I can't change RecNo from TfrxDataSet since its readyOnly property, any workaround will be appreciated.

Regards.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 6:37PM
    if you are trying to select a record either parameterize your query or use urls.
    run the main demo and look at other features, "urls,anchors" report or
    under internaldatasets, "Internal query report" or
    under ndialogs and script, "choosing records to print" report.
  • edited 6:37PM
    I do wonder why do you try to identify a certain row in a query result by its recno, and this RecNo comes from other dataset. In general query returns a set of rows in a specyfic order (ORDER BY clause). So in my opinion it is not a good method to search within a query using RecNo.

    I have all above doubts because I do NOT know what do you really need to point in the second query or what kind of relation between those two DataSets you already have or want to make.

    Write some words about the reality of those queries and it will help to understand your need and to show you the way of further tests.

    Maybe that what is good to you is a classic master-detail relation of two queries (datasets). If so then you may find here (this forum - a few days ago) examples of how to use WHERE condition in queries after design time, when report is in use. Rcsoft & Gorousek have started similar topics.

    And a bit more - have a look at TDataSet.Locate( Keyfields, KeyValues, Options). I was close to use this method but gave up, as I did not found explanation of TLocateOptions in documentations - maybe you'll be the lucky one and you'll get through it :-)

    Mick
  • edited 6:37PM
    Thanks for reply [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I have a look at all the examples in the demo and related question in th forum. URL/anchors doesn't fit the needs, and can't use query param in this case... The issue is simple: print selected record from TDataSet to TfrxADOQuery (they have the same recCount) its ok to setup Ranges (rbCurrent...) and print one record but is there better way than using DialogPage[/img][img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Actually I am trying to set PageNo at runtime like that:[/img]
    TfrxPreview(frxReport.Preview).PageNo := ADataSet.RecNo;
    
    So, which event should I use?
  • edited 6:37PM
    A while ago it seemed to be quite easy to solve [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I invited you to say more and now I see the forest is thicker and thicker[/img][img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> So you have one dataset with selected (in any way) some rows. And you want to print information from the second dataset using exactly the same recno of both datasets. I assume that RecNo is a kind of index key in both dataset. If this RecNo can be made as a column value in both dataset (queries) then you may try to use my former idea (Locate method). In a meantime I looked at compiled demo and here you have what I found: 1. ADOQuery1 = select * from customer 2. ADOQuery2 = select * from customer OnBeforePrint event for MasterData1 (with ADOQuery1 attached) I used ADOQuery2.Locate('custno', <ADOQuery1."CustNo">, 0) and within the same obp event I put <ADOQuery2."Company"> in other memo on this band. So Locate works[/img][img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> And you can use it if you can change RecNo into a column value. But if rec number can not be changed into a column, then I other solution is needed. I'm still not sure if you really need to use TWO queries? Which query (dataset) is attached to your MasteBand? And why do you try to select something using a DialogPage? I'm sorry for this "poem", but I have no idea how to work with RecNo of your two datasets and I try to understand the relation between them to find solution within area where I feel good - I mean queries[/img][img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Mick PS. It seems to be a solution, but not an elegant one[/img][img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> within OnBeforePrint event fired for band with ADOQuery1 use code like below: ADOQuery2.First // stay at the top for i:=1 to ADOQuery1.RecNo-1 do ADOQuery2.Next; // get the same RecNo position in second DataSet[/img]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.