Setting TableRelation for Request Form variables

KeithMMooreKeithMMoore Member Posts: 59
I have a simple request form with 2 vars for user input - NewType and NewCode

NewType has a table relation to a Type table - no problem

NewCode needs a table relation to the Code table which needs be filtered on the NewType value just entered and that is where I am stuck.

- Request Form fields do not provide for OnValidate
- NewCode.TableRelation property's OnAssist does not bring up anything
- I have tried entering a WHERE clause manually in the TableRelation property but either 1) I have not figured out how to enter it correctly or 2) it does not work for a variable.

I am convinced that this should be fairly simple but I have not figured it out yet. Thanks in advance for any assistance.

Comments

  • SLF25SLF25 Member Posts: 37
    setfilters on record;
    
    IF FORM.RUNMODAL(0,Rec) = ACTION::LookupOK THEN BEGIN
      Text += Rec.Code;
      EXIT(TRUE);
    END;
    
    

    This goes to OnLookup trigger. I hope this helps.
  • KeithMMooreKeithMMoore Member Posts: 59
    SLF25 wrote:
    setfilters on record;
    
    IF FORM.RUNMODAL(0,Rec) = ACTION::LookupOK THEN BEGIN
      Text += Rec.Code;
      EXIT(TRUE);
    END;
    
    

    This goes to OnLookup trigger. I hope this helps.
    The problem I have though is that on the report Request Form, there is no OnLookup or OnValidate for the variables so I do not see where this code can go.
  • DenSterDenSter Member Posts: 8,305
    The textbox on the requestform has an OnLookup trigger, that's where you put this code.
  • KeithMMooreKeithMMoore Member Posts: 59
    When I press F9 while the Request Form text box is highlighted I am getting the following:

    Report - OnActivate()

    Report - OnDeactivate()

    Report - OnFormat(VAR Text : Text[1024];)

    Report - OnBeforeInput()

    Report - OnInputChange()

    Report - OnAfterInput(VAR Text : Text[1024];)

    Report - OnValidate()

    Report - OnAfterValidate()

    Report - OnLookup(VAR Text : Text[1024];) : Boolean

    Report - OnDrillDown()

    Report - OnAssistEdit()


    I am not getting OnValiadate or OnLookup options... ?????
  • kinekine Member Posts: 12,562
    I do not understand you. You included list of triggers including OnValidate and OnLookup and you are writing that
    I am not getting OnValiadate or OnLookup options... ?????
    Did you go through the list? :wink:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • KeithMMooreKeithMMoore Member Posts: 59
    I am getting them saying "Report" - not the field name, which is what is always there with fields. So, even though it says "Report" in this case, it really doesn't mean "report" like it does elsewhere; it means the text box? :-s
  • KeithMMooreKeithMMoore Member Posts: 59
    Guess it does mean the text box - it worked fine - thanks [PS - I'm really not that dense :? ]
  • DenSterDenSter Member Posts: 8,305
    [PS - I'm really not that dense :? ]
    That's what you SAY, but.... :mrgreen:
    Glad you found it though
  • KeithMMooreKeithMMoore Member Posts: 59
    Well, opening the filtered list is working fine but it is not returning the value to the field on the Request Form. Here is the code for CurrCode OnLookup:

    CatCodes.SETRANGE(Type,CurrType);

    IF FORM.RUNMODAL(37001262,CatCodes) = ACTION::LookupOK THEN BEGIN
    CurrCode := CatCodes.Code;
    EXIT(TRUE);
    END;

    Debug shows 'CurrCode' being assigned the value properly but it is not passing back into the Req Form. There is no TableRelation on CurrCode [Code 10]; all other properties are defaults as far as I can tell. ?? Maybe I'm denser than I thought :shock:
  • kinekine Member Posts: 12,562
    You mas use this code:
    IF FORM.RUNMODAL(37001262,CatCodes) = ACTION::LookupOK THEN BEGIN
      Text := CatCodes.Code;
      EXIT(TRUE);
    END;
    

    to set the value correctly if this code is called from OnLookup.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • KeithMMooreKeithMMoore Member Posts: 59
    Thanks so much - I forgot that I needed that the Text var was the variable being returned. :oops:
Sign In or Register to comment.