Page 1 of 1

What's my best option? Subform, iframe or something else?

Posted: Thu Feb 23, 2023 4:27 pm
by Keith-i
I need to produce a list of results (and ultimately print a report) based upon selecting a road from an existing table and having the resulting list show all entries from the other table where the road_id matches.

If I create a fastform that accesses my roads table I can filter the data and select the road I am interested in. However, as soon as I select a road it takes me to an edit screen whereas what I really need is another form that shows all the related data based on that roads #RECORD_ID#. Am I missing the blindingly obvious?

Or am I better using a subform or iframe on the main browse form screen? All thoughts welcomed inclduing any other way of doing it.

Re: What's my best option? Subform, iframe or something else?

Posted: Thu Feb 23, 2023 4:45 pm
by kev1n
I would do it in the same way as you've done before. 2 Browse and filter the 2nd based on the selection in the 1st.

Re: What's my best option? Subform, iframe or something else?

Posted: Fri Feb 24, 2023 3:45 pm
by Keith-i
Hi kev1n

I'm having a bit of difficulty setting up some JS using nuSelectBrowse. My plan is to click on a road name in my tblRoads which will then open a new browse form (frm_values) which shows related data from the tbl_Properties and tblValues tables. Here is the custom code on the roads form (frm_roads). The primary key is a foreign key in tbl_Properties

Code: Select all

function nuSelectBrowse(e) {

var roadID = $(e.target).attr('data-nu-primary-key');
nuSetProperty('roadref',roadID)
nuForm('frm_values', '','' , '', '0');

return false;
}
Then in my second browse form (frm_values) I have this SQL to theoretically show every record that matches the hash cookie #roadref# in the id_Roads field .

Code: Select all

SELECT
 tblValues.*,
    tblProperties.*

FROM
    tblValues
        JOIN tblProperties ON tblValues.id_Properties = tblProperties.idProperties

WHERE
    ((tblProperties.id_Roads = '#roadref#'))
For convenience I also attach a diagram of my tables.

When I click on a road I just get an empty browse form showing, which doesn't even have any column headings. Neither debug or F12 help me.

Re: What's my best option? Subform, iframe or something else?

Posted: Fri Feb 24, 2023 4:01 pm
by kev1n
nuForm() expects a Form ID (e.g. "63e3d7bd4e10f60"), not a Form Code. Press Ctrl+Shift+M on the form you'd like to open to see it.

Re: What's my best option? Subform, iframe or something else?

Posted: Fri Feb 24, 2023 4:22 pm
by Keith-i
I see, thanks!
I am a step closer in that I now at least get a browse form opening up. However it doesn't show any data. If I remove the #roadref# from my SQL and put in a random road id I get results so I know the subsidiary form is working. It looks like it's not passing the hash cookie through.

Re: What's my best option? Subform, iframe or something else?

Posted: Fri Feb 24, 2023 4:28 pm
by kev1n
Try setting a global Hash Cookie:

Code: Select all

nuSetProperty('roadref',roadID, true)

If that doesn't work either, I have another trick up the sleeve...

Re: What's my best option? Subform, iframe or something else?

Posted: Fri Feb 24, 2023 4:30 pm
by Keith-i
That's the ticket. Thanks again.