Forums › Forums › SIMPOL Programming › Setting Master record in second window
- This topic has 3 replies, 2 voices, and was last updated 14 years, 3 months ago by
Dan Jinks.
- AuthorPosts
- August 14, 2011 at 6:53 pm #262
Dan Jinks
ParticipantI’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
August 14, 2011 at 11:43 pm #1906Dan Jinks
ParticipantGot 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?
>
> -DanAugust 15, 2011 at 6:58 pm #1907Michael
KeymasterOn 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 ifI'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
August 15, 2011 at 11:23 pm #1908Dan Jinks
ParticipantHello 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.
-DanOn 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 - AuthorPosts
- You must be logged in to reply to this topic.