I have a table form-guides which has a related table called questions. The questions table has a primary key with three fields (id_questions, id_form_guides, and id_projects).
When a user clicks on a button on the form_guides form, I want to display all of the related questions in a dialog window.
The code I am using is:
var myMain = currentcontroller.getName()
var myForm = application.getMethodTriggerFormName();
//plugins.dialogs.showInfoDialog( "myForm", myForm)
var myGuide = forms[myForm].id_form_guides
var myProj = forms[myMain].id_projects
var query = 'SELECT questions.id_questions, questions.id_form_guides, questions.id_projects FROM questions WHERE questions.id_form_guides = ' + myGuide + ' and questions.id_projects = ' + myProj + ' order by questions.id_questions, questions.id_form_guides, questions.id_projects';
//application.output(query)
forms.questions.controller.loadRecords(query)
application.showFormInDialog(forms.questions,5,130, 710, 400, " Questions for Project: " + forms[myMain].name_long + ", Form Guide: " + forms[myForm].name)
When this runs, I get the right number of records but the wrong data. The first record in the foundset is repeated in all of the records.
Interestingly, I have another set of nearly identical tables called question_groups and project_questions which are setup virtually identical. When I do the exact same thing with these forms everything works fine.
Here is the code that works fine:
var myMain = currentcontroller.getName()
var myForm = application.getMethodTriggerFormName();
//plugins.dialogs.showInfoDialog( "myForm", myForm)
var myGroup = forms[myForm].id_question_groups
var myProj = forms[myMain].id_projects
var query = 'SELECT project_questions.id_project_questions, project_questions.id_question_groups, project_questions.id_projects FROM project_questions WHERE project_questions.id_question_groups = ' + myGroup + ' and project_questions.id_projects = ' + myProj + ' order by project_questions.id_project_questions, project_questions.id_question_groups, project_questions.id_projects';
//application.output(query)
forms.project_questions.controller.loadRecords(query)
application.showFormInDialog(forms.project_questions,5,130, 710, 400, " Questions for Project: " + forms[myMain].name_long + ", Question Group: " + forms[myForm].name)
Can you see what I am doing wrong???
I made a sample of the problem if you want to look at it.
Thanks for your help.