Options

hOw can i translate the string variable to record

madhuri.sysmadhuri.sys Member Posts: 13
hi all,
i am using ado library for establish a connection with MS-Access database.
MS-Access table contains Navision Table Names.

i have got a string from a query dynamically, it contains Navision Table Name.
now i would like to initialize the Table with that name.
so that i can modify the navision Data.
hOw can i translate the string variable to record variable?

plz concern this as seriously....

thanks,
Ramesh.

Comments

  • Options
    EugeneEugene Member Posts: 309
    This sample should give you a hhint on how to acomplish your task.

    Define local variable of type record and subtype 2000000001 Object
    also define a local variable Table of type RecordRef.

    // This little sample of code will count the records in a table

    Object.SETRANGE(Type,Object.Type::Table); // Only Tables have records. What?! You didn't know that?
    Object.SETRANGE(Object.ID,1,10); // For this sample, count only records in tables 1..10.
    Object.FIND('-'); // IF THEN? Hopefully you have some object in your database!

    REPEAT
    Table.OPEN(Object.ID); // Open Record reference to current table.

    MESSAGE(Text000,Object.Vardas,Table.COUNT); // Show you what was found.
    UNTIL Object.NEXT = 0;
  • Options
    EugeneEugene Member Posts: 309
    so in your case something like that should work (not tested)

    Object.SETRANGE(Type,Object.Type::Table);
    Object.SETFILTER(Object.Name,'TableNameYouGetFromADO');
    IF Object.FIND('-') THEN Table.OPEN(Object.ID);
  • Options
    madhuri.sysmadhuri.sys Member Posts: 13
    that is OK..
    but i am also getting the field names dynamically from Access table.
    then i need to assign the valuesin navision like this...
    here field name is a Text variable.


    field name:=format(recorset.fields.item(i).value);
    recordref.init;
    recordref."field name" := 'asdf';
    recordref.insert;


    here i am getting the field name from another recordset.

    while compiling it is getting an error message that the fieldname is nota field in the record.


    if u mean the same then jus verify this again...

    thaks..
  • Options
    EugeneEugene Member Posts: 309
    very similar to above 'Object' table there is a table called 'Field'

    so define a variable (i called it reclField) of type Record of subtype Field

    then use the following:
    YourFieldName:=format(recorset.fields.item(i).value);
    recordref.init;
    reclField.SETRANGE(TableNo, recordref.NUMBER); // set range on table number
    reclField.SETRANGE(FieldName, YourFieldName); // set range on field name 
    IF reclField.FIND('-') // if there is a field YourFieldName in the table number recordref.NUMBER
    THEN BEGIN // then u get it by its number reclField."No."
     recordref.FIELD(reclField."No.").VALUE('asdf'); // assigning a new value
     recordref.insert; 
    END;
    

    //by the way how is it going there in India with Navision products and life in general ? ;)
Sign In or Register to comment.