Multi purpose use search form

Rani_ShouraRani_Shoura Member Posts: 15
Hello Forum,

I have a tricky thing to do arround, I'm working on a Customized Handheld terminal Application with Navision, now the application is almost done, the users are requisting to have a barcode alternative using search screens.

Now I have to create something arround 15 forms "PDT size" only for that purpose, is there is any way to have the following:

Have one generic form for searching where I pass the recordset might be a sales header, purchase header, item list, Lot Nos
[-o<

Comments

  • kinekine Member Posts: 12,562
    You can have form to only get the barcode from the user and than you can search all the tables you want for the relevant record and open the appropriate form with it.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Rani_ShouraRani_Shoura Member Posts: 15
    kine wrote:
    You can have form to only get the barcode from the user and than you can search all the tables you want for the relevant record and open the appropriate form with it.

    Thanks for the reply, it looks that I didn't describe my self well, all the barcode scanning and logic is done, but sometimes, for various reasons, there will be no barcodes and orders with the user so I have to give him a select from a list function, now I have like 7 fields which are scanned, and I don't want to have 7 forms "Saving :)" so I need to have one form with a table box where I can bind to different data sets, where user will get the Ok Cancel buttons and select a key.


    Regards
  • kinekine Member Posts: 12,562
    Just base the form on some temporary table having the code as primary key or create your own, which you will fill by the values from table you need. It could be done, I am using it already... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Rani_ShouraRani_Shoura Member Posts: 15
    kine wrote:
    Just base the form on some temporary table having the code as primary key or create your own, which you will fill by the values from table you need. It could be done, I am using it already... :-)


    Hi Kine,

    Thank for your prompt response, can you shade some light on the "which you will fill by the values from table you need".

    Thanks a million
  • kinekine Member Posts: 12,562
    Assume, that you have table with fields "Code" and "Description". Than you can create form (will be read-only) and add this code:
    -----------------
    OnOpen
    
      RecRef.OPEN(BaseTableID);  //table, from which you want to take the values
      RecRef.FIND('-');
    
    -----------------
    OnFindRecord
    
      FieldRef := RecRef.FIELD(CodeFieldID); //ID of the field with the code value in the base table
      FieldRef.VALUE := Code;
      FieldRef.SETFILTER(GETFILTER(Code));
      FieldRef := RecRef.FIELD(NameFieldID); //ID of the field with name in the base table
      FieldRef.VALUE := Description;
      FieldRef.SETFILTER(GETFILTER(Description));
      Result := RecRef.FIND(Which);
      FieldRef := RecRef.FIELD(CodeFieldID);
      Code := FieldRef.VALUE;
      FieldRef := RecRef.FIELD(NameFieldID);
      Description := FieldRef.VALUE;
      EXIT(Result);
    
    ----------------
    OnNextRecord
    
    
      FieldRef := RecRef.FIELD(CodeFieldID);
      FieldRef.VALUE := Code;
      FieldRef.SETFILTER(GETFILTER(Code));
      FieldRef := RecRef.FIELD(NameFieldID);
      FieldRef.VALUE := Description;
      FieldRef.SETFILTER(GETFILTER(Description));
      Result := RecRef.NEXT(Steps);
      IF Result <> 0 THEN BEGIN
        FieldRef := RecRef.FIELD(CodeFieldID);
        Code := FieldRef.VALUE;
        FieldRef := RecRef.FIELD(NameFieldID);
        Description := FieldRef.VALUE;
      END;
      EXIT(Result);
    

    If you correctly set the values of variable CodeFieldID, NameFieldID and BaseTableID, you have generic for able to open any table which have Code as primary key and some description in another field. You can use some setup table to keep these IDs etc... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Rani_ShouraRani_Shoura Member Posts: 15
    Hi,

    I don't have a dev env under my hand now, I'll test it and get back to you, but from what I understand, it's a perfect solution. =D>

    Thanks alot.


    Have a nice day
Sign In or Register to comment.