no changes in db until transaction made

lucianaluciana Member Posts: 43
Hi to all.
I have a proble with a subform.
When I press F3 in mainform I would subform become new. So I went into subform properties, in SuformLink I put
"Line No."=FIELD("Object No.")

So, if I have a new Objet pressing F3 Button, I should have a new subform, BUT I cannot open the form because a message error appears to me saying that it isn't possible to me making changes in db until a transaction is made.

If I don't put anything in SubformLink properties, form opens .
How could I solve that?

Thanks
Luciana
«1

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Have you seen Sales Order/Invoice and Purchase Order/Invoice? how they are working?
  • lucianaluciana Member Posts: 43
    Yep. They put In SubformLink property (Document.No) = FIELD(No.).

    I have (Line No.) = FIELD(No.)

    where's the difference?
    :shock:
    Luciana
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    What are the Primary Keys of header Form and SubForm?
  • lucianaluciana Member Posts: 43
    Primary Key in main form is "Object No."
    Primary Key in subform is "Line No.", "Item No."

    thanks
    Luciana
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Is Object No. = Line No.?
    or Line No. is different?
  • lucianaluciana Member Posts: 43
    They are two different subjects
    Both Line no and Object No are type CODE.
    Line Nro needs to use ascending order in subform.
    They are both automatically inserted as No series.
    When I have a new Object No, subform has to be reset (but not deleted)

    EDIT: I know, it's not NAV way, but it's an example of exercize to me in calling table, make form, subform, see how no. series work, etc etc. :)
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    In Sales And Purchase Subforms (Document.No) = FIELD(No.).
    both fields refer same data..
    I feel the design of your tables is wrong..
    IF you ahve no data in tables add Object No to Subform table and link both of them.

    EDIT : Object no in subform should be part of primary key as in sales and Purchase Docuament No.
  • lucianaluciana Member Posts: 43
    In Sales And Purchase Subforms (Document.No) = FIELD(No.).
    both fields refer same data..
    I feel the design of your tables is wrong..
    IF you ahve no data in tables add Object No to Subform table and link both of them.

    EDIT : Object no in subform should be part of primary key as in sales and Purchase Docuament No.

    In Subform Table I have Object No and Line No yet.. and both are pare of primary key...
    There's another way to emulate the SubformLink property?

    Thanks
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    If you have Object No in Subform table also use
    (Object No.) = FIELD(Object No.).
  • lucianaluciana Member Posts: 43
    If you have Object No in Subform table also use
    (Object No.) = FIELD(Object No.).

    I've done this yet but when I insert a new record in subform, it delete record inserted before...
    And I set subform property MultipleNewLines to Yes
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    IS DelayedInsert YES?
    IS AutoSplitKey YES?

    Line No. should be at last in the Primary key of subform table.
  • lucianaluciana Member Posts: 43
    edited 2011-07-05
    Delayed insert is set to yes.
    Autosplit key needs that Line No to be an integer/decimal, it's a code.. If I don't put Line No as a code, I cannot use properties of subfotm anyway because Object No and Line No are supposed to be the same data type..
    Line No is a primary key and it's as last of primary keys
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Line No should be Integer
    why should it be same as Object No when you have Object No. field in Subform table?
  • lucianaluciana Member Posts: 43
    Line No should be Integer
    why should it be same as Object No when you have Object No. field in Subform table?

    I don't know.. Object No is a code and must be a code (it's as order No in purchase table). Whan I put Line no as an integer, and I used subform properties, Nav said to me that Object No and Line No must be same data type. So I transformed Line No as a code that is automatically numbered form table No. Series.

    That worked but the only thing I can't do is open a new subform when I press F3 .
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    In Sales And Purchase Subforms (Document.No) = FIELD(No.).
    both fields refer same data..
    I feel the design of your tables is wrong..
    IF you ahve no data in tables add Object No to Subform table and link both of them.

    EDIT : Object no in subform should be part of primary key as in sales and Purchase Docuament No.

    I already told you to add Object No in subform table.

    The logic which you are using die not work. :thumbsdown:
  • lucianaluciana Member Posts: 43

    I already told you to add Object No in subform table.

    The logic which you are using die not work. :thumbsdown:

    And I told you that Object No is both in subform table and in mainform table, but, when I insert new record, I cannot see anymore the record inserted before.
  • SogSog Member Posts: 1,023
    if you say in your subformlink that the mainrec.object no. = subrec.line no. then ofcourse NAV is going to complain that the types should match. Remove this link and only make mainrec.object no. = subrec.object no.
    Line no. should not be used in the link!
    Second, line no. is used with no. series? Ask yourself why you did that and see the error of your way.
    Line No. ought to be integer (best practice) so you can use autosplitkey.
    Line No. should be the identifier which identifies the uniqueness of one line, while the object no. combines the lines in one document.

    Maybe it's best if you start over with the tables and normalise those.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • lucianaluciana Member Posts: 43
    Sog wrote:
    if you say in your subformlink that the mainrec.object no. = subrec.line no. then ofcourse NAV is going to complain that the types should match. Remove this link and only make mainrec.object no. = subrec.object no.

    No, I wrote that if I put in SubformLink property subform.LineNo = FIELD(Mainform.ObjectNo), NAV tell me that I should have a transaction before modifying database.
    Line no. should not be used in the link!
    Second, line no. is used with no. series? Ask yourself why you did that and see the error of your way.
    Yes, is used with No. Series because I needed something that distinguished a field from another to avoid that when I insert a record, it moves up or down in the form .
    Line No. ought to be integer (best practice) so you can use autosplitkey.
    I tried to do this. But if I leave Line No as an integer, then, when I set subformLink property , Nav shows me an error that says:
    It's impossible. Data don't match.
    Line No. should be the identifier which identifies the uniqueness of one line, while the object no. combines the lines in one document.
    I haven't understood "combinesz the lines in one document"
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    luciana wrote:
    I tried to do this. But if I leave Line No as an integer, then, when I set subformLink property , Nav shows me an error that says:
    It's impossible. Data don't match.
    First set subform.ObjectNo = FIELD(Mainform.ObjectNo) in Subform link and then change the lineno to integer.
  • SogSog Member Posts: 1,023
    *attempt no. 2

    main rec: "object no.", "object name", (other important fields but not for now) (key= object no.)
    sub rec: "object no.", "Line no." , "item no.","description", other fields) (key=object no. & line no.)
    object no. in both tables is the same datatype.
    Line no. is integer.

    If the table is not designed like this, then don't start going for form & subform.

    Don't bind "Line no." with "no. series": because that will effectively make sure that all the lines no matter under what object no. will be unique. (which is unneccesary). You only have to distinguish lines in the same "object".

    Now let's design the form.
    You know how to bind the tables, so let's skip that and go straight to the subformlink.
    The only entry there should be Object no. = Object No.
    If there is a mention of "line no." remove it.
    In the subform set autosplitkey on. That way your integer "line no." will be automaticaly filled in when inserting a new line.
    If you have problems grasping this concept, please contact a senior from your company.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Sog wrote:
    If you have problems grasping this concept, please contact a senior from your company.
    :thumbsup: :thumbsup: :thumbsup:
  • BeliasBelias Member Posts: 2,998
    Sog wrote:
    If you have problems grasping this concept, please contact a senior from your company.
    sorry for the intermission, but i think that WE are her senior developer... :(
    http://www.mibuso.com/forum/viewtopic.php?f=23&t=47596
    it's not fair that she's been threw from her boss in nav development without manuals, (as you can read from the link), but it's also not fair (and not "time-effective") to ask a step by step guide in a forum...you have to PRETEND study materials from your boss.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • lucianaluciana Member Posts: 43
    Belias wrote:
    Sog wrote:
    If you have problems grasping this concept, please contact a senior from your company.
    sorry for the intermission, but i think that WE are her senior developer... :(
    http://www.mibuso.com/forum/viewtopic.php?f=23&t=47596
    it's not fair that she's been threw from her boss in nav development without manuals, (as you can read from the link), but it's also not fair (and not "time-effective") to ask a step by step guide in a forum...you have to PRETEND study materials from your boss.

    thank you for your comprehension... :)
    That's true, I have no senior developer to ask for.
    Unfortunately, the project I should have work on is over but my boss told me I have to continue "homeworks". So I'm alone in this world and I couldn't have manual .
    The only resource I could look at is this forum.

    I know that I could not ask for a step by step guide and real time responses here, but I appreciate your helpfulness very much.
    Thank you
  • SogSog Member Posts: 1,023
    Ok, then let's take this one step at a time.
    The first thing you should comprehend is the tables, their relations, behaviour, ...
    I hope you have some knowledge of databasedesign, that will make this step a whole lot easier.

    Tables consists of a number of fields. One (or more) field(s) will act as primary key, aka a unique identifier per record. Which means that a primary key will always be once in a table.
    to create a relation between tables, one of the tables will have the primary key of the foreign table. (aka foreign key)
    In a normal parent-child relation, the child table will have a primary key which consists out of the primary key of the parent table and it's own unique identifier. (in nav mostly line no.)
    That way we can identify just by the parent's primary key all the records related in the child table. (and that connection is what we put in the subformlink)

    The line no. of the child table can be the same, but the combination parent and line no has to be unique. Because this can be the same, we often don't use (like never) the no. series to fill in the line no. because we only have to distinguish lines in the same document. The No. Series table is handier when u have a single field primary key.
    We often (like always) use integer for line no. because then the autosplitkey function in forms will be available.
    The autosplitkey function on a form enables the last field of the source table's primary key to be split or added. (ie: no next line, last keyfield {line no.} + 10000, else a number in between the previous and current line)

    The last thing I'd like to say is F1, the help function is awesome for beginners. You'll find an answer to a lot of your possible questions there. If you want to know more about code, go to the start page of the help and click C/SIDE reference guide. (also a help but for code).
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • lucianaluciana Member Posts: 43
    I don't understand anymore.
    Can I post my fobs, so someone could look at and suggest where I'm wrong?
  • SogSog Member Posts: 1,023
    export as txt, or copy pasta the code. If that's no option, then yes you may post the .fobs.
    Mention the nav version too please.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • lucianaluciana Member Posts: 43
    shit!
    I apologize, here the correct link:
    http://uploading.com/files/b42c1b78/tablesForms.fob/

    luciana
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Download Modified objects from
    http://uploading.com/files/4ced7c3f/tablesForms%2BMOD.fob/

    No need to enter "Nro Riga" in subform..
    After inserting the record in subform, it will automatically assign No.
Sign In or Register to comment.