Options

On button click Read from table current row

giovannixyzgiovannixyz Member Posts: 13
edited 2010-07-27 in Navision Attain
How Can I read from table

I added button on form, in section onPush()

I added code

string_my:= Name_of_record."Field_in_table";
Message(string_my);

allways is is empty, but in table is data.
Please help

Comments

  • Options
    alok_didaalok_dida Member Posts: 73

    string_my:= Name_of_record."Field_in_table";
    Message(string_my);

    Did u write
    Name_of_record.Get;
    before these above two statements?
  • Options
    DenSterDenSter Member Posts: 8,304
    No need for GET. When you're on a form, the current record is called 'Rec'. When you select it from the object browser, it even gets left out. Try this code:
    MESSAGE(FORMAT("Field In Table"));
    
    Leave out the "name of record" part
  • Options
    kinekine Member Posts: 12,562
    "Name of the record" to access the current record is "Rec". But you can skip the Rec. part because all code on the form is virtually done with command "With rec do" (thus Rec. is not needed in the code, it will be added automatically in the background). I recommend to read basic documentation for developers to see how the Rec. and xRec. variables are working...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    giovannixyzgiovannixyz Member Posts: 13
    name of record when I read was to much. thanks. =D>

    now I have in string name, address and post code

    and I try to write into record

    with name_of_record."name_of_field" := string_name;

    I also try "name_of_field" := string_name;?
  • Options
    DenSterDenSter Member Posts: 8,304
    It doesn't look like you need the "name_of_record" variable. Just like the other example, you can assign values to just the field name, that will set those values to the current record on the form.

    You know, instead of trying to come up with something like 'name_of_record' and 'name_of_field', why don't you just use the same record and field names that you are working with? Also, explain to us what the functional requirement is, so we understand what it is that you're trying to do. There might be a different way to approach your problem.
  • Options
    giovannixyzgiovannixyz Member Posts: 13
    I try to modify table Sales header. Field "Sell-to Customer Name"

    I have record GlavaProd on table Sales header

    complete code will be in section OnPush() in my Button

    GlavaProd.GET;

    GlavaProd."Sell-to Customer Name" := ime_priimek; // this is my string
    GlavaProd.Modify;

    on button click there is no change on form.
  • Options
    DenSterDenSter Member Posts: 8,304
    Think about what you're trying to do. You are trying to set the sell-to customer name on the sales header, so why are you doing a MODIFY on your GlavaProd variable? Where are you setting the value of your ime_priimek variable?

    I am assuming that you are trying to retrieve the value from the GlaveProd table, and setting the field on the sales header with the name from that record.
    OnPush()
    
    IF GlavaProd.GET THEN
      VALIDATE("Sell-to Customer Name",GlavaProd."Sell-to Customer Name");
    
    or simply assigning the field:
    OnPush()
    
    IF GlavaProd.GET THEN
      "Sell-to Customer Name" := GlavaProd."Sell-to Customer Name";
    
    And if the value doesn't show up then add a CurrForm.UPDATE in there.
  • Options
    giovannixyzgiovannixyz Member Posts: 13
    Thanks for help everything was ok, but I didn`t know about CurrForm.UPDATE;
    when I added this it started to work.

    funny that when I walked by Customers (form didnt refresh it self`s)
    anyway now works, thanks again. =D>
Sign In or Register to comment.