Skip to content

Setting Master record in second window

Forums Forums SIMPOL Programming Setting Master record in second window

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #262
    Dan Jinks
    Participant

    I’m opening a second window in my app and want the same master record on both forms. I have set the second form’s amster record like this: //the notes form should have same master record as the main form mainappw =@ appw.app.windows.getfirst() mainform =@ mainappw.form r =@ mainform.masterrecord appw.form.setmasterrecord(r) I have no errors and the secondary window and form display, but with the first record in the master table. I also added a selectrecord() function but this does not help. Do I really need to perform a select key operation when I already have the correct record object? What am I missing? -Dan

    #1906
    Dan Jinks
    Participant

    Got it working. For those who may want to sync multiple windows, here
    is what I did:
    //notes form should have same master record as the main form
    mainappw =@ appw.app.windows.getfirst()
    mainform =@ mainappw.form
    maintable =@ mainappw.form.mastertable
    mainr =@ mainform.masterrecord
    mainlastfirstfld =@ getfield(maintable.table, "Last_First")
    lastfirstkey = getfieldstrvalue(mainappw, mainlastfirstfld, mainr.record)
    if lastfirstkey > ""
    fld =@ getfield(appw.form.mastertable.table,"Last_First")
    if fld =@= .nul
    wxmessagedialog(appw.w, "Error retrieving index field from
    Notes Master Table", sAPPMSGTITLE, "ok", "error")
    else
    r =@ appw.form.selectkey(lastfirstkey, fld.index, found=found,
    error=e)
    // lets check that the index has been set
    masteridxname = appw.form.masterrecord.record.index.field.name
    end if
    end if

    -Dan

    On 8/14/2011 2:53 PM, djinks wrote:
    > I'm opening a second window in my app and want the same master record on
    > both forms. I have set the second form's amster record like this:
    >
    > //the notes form should have same master record as the main form
    > mainappw =@ appw.app.windows.getfirst()
    > mainform =@ mainappw.form
    > r =@ mainform.masterrecord
    > appw.form.setmasterrecord(r)
    >
    > I have no errors and the secondary window and form display, but with the
    > first record in the master table. I also added a selectrecord() function
    > but this does not help.
    >
    > Do I really need to perform a select key operation when I already have
    > the correct record object? What am I missing?
    >
    > -Dan

    #1907
    Michael
    Keymaster

    On 15/08/2011 00:43, djinks wrote:
    > Got it working. For those who may want to sync multiple windows,
    > here is what I did:
    > //notes form should have same master record as the main form
    > mainappw =@ appw.app.windows.getfirst()
    > mainform =@ mainappw.form
    > maintable =@ mainappw.form.mastertable
    > mainr =@ mainform.masterrecord
    > mainlastfirstfld =@ getfield(maintable.table, "Last_First")
    > lastfirstkey = getfieldstrvalue(mainappw, mainlastfirstfld,
    > mainr.record)
    > if lastfirstkey > ""
    > fld =@ getfield(appw.form.mastertable.table,"Last_First")
    > if fld =@= .nul
    > wxmessagedialog(appw.w, "Error retrieving index field
    > from Notes Master Table", sAPPMSGTITLE, "ok", "error")
    > else
    > r =@ appw.form.selectkey(lastfirstkey, fld.index,
    > found=found, error=e)
    > // lets check that the index has been set
    > masteridxname = appw.form.masterrecord.record.index.field.name
    > end if
    > end if

    I'm glad that you got it working, but it should have worked by simply
    setting the record.

    If you have a reproducible example, I would like to see it. Unless you
    disable the refresh, it should show the record in the form. What it
    won't do without a selectcurrent(), is to activate the links.

    Ciao, Neil

    #1908
    Dan Jinks
    Participant

    Hello Neil,

    I found an logic error in the original project. I was not setting the
    form's mastertable and was using the form's default mastertable, which
    was from from another folder and had less records. I went back and
    changed the logic to copy BOTH mastertable and masterrecord to the new
    appw.form. All goes well (after other revisions) until I leave the
    opennotes function (for the opening the second window). I've sent you an
    email with sample project to review.

    Hope you can help.
    -Dan

    On 8/15/2011 2:58 PM, Neil Robinson wrote:
    > On 15/08/2011 00:43, djinks wrote:Hello Neil,

    I found an logic error in the original project. I was not setting the
    form's mastertable and using the form's default mastertable, which was
    from from another folder and had less records. I'll went back and
    changed the logic to copy BOTH mastertable and masterrecord to the new
    appw.form. All goes well (after other revisions) until I leave the
    opennotes function. I've sent you a sample project to review.

    Hope you can help.
    -Dan
    >> Got it working. For those who may want to sync multiple windows,
    >> here is what I did:
    >> //notes form should have same master record as the main form
    >> mainappw =@ appw.app.windows.getfirst()
    >> mainform =@ mainappw.form
    >> maintable =@ mainappw.form.mastertable
    >> mainr =@ mainform.masterrecord
    >> mainlastfirstfld =@ getfield(maintable.table, "Last_First")
    >> lastfirstkey = getfieldstrvalue(mainappw, mainlastfirstfld,
    >> mainr.record)
    >> if lastfirstkey> ""
    >> fld =@ getfield(appw.form.mastertable.table,"Last_First")
    >> if fld =@= .nul
    >> wxmessagedialog(appw.w, "Error retrieving index field
    >> from Notes Master Table", sAPPMSGTITLE, "ok", "error")
    >> else
    >> r =@ appw.form.selectkey(lastfirstkey, fld.index,
    >> found=found, error=e)
    >> // lets check that the index has been set
    >> masteridxname = appw.form.masterrecord.record.index.field.name
    >> end if
    >> end if
    >
    >
    > I'm glad that you got it working, but it should have worked by simply
    > setting the record.
    >
    > If you have a reproducible example, I would like to see it. Unless you
    > disable the refresh, it should show the record in the form. What it
    > won't do without a selectcurrent(), is to activate the links.
    >
    > Ciao, Neil

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.