LO 22.214.171.124-snap1, Ubuntu 18.04 with all updates. Split data from forms using Firebird back end.
I have a Base Form (Pic below) that shows a list of students in a listbox. It actually consists of :
- frmStudentSelect - editable details,
attached directly to table.
- frmStudList - holds listbox “lstStudents” of
student summary details. Fed by
query against students table.
- sfClasses - subform of frmStudlist,
holds listbox “lstClasses” of summary of classes
for currently selected student. Fed
by SQL string.
- Secret, a hidden form with a hidden
Clicking on a specific student in “lstStudents” does 2 things - shows the classes linked to that student in “lstClasses” and also fills “frmStudentSelect” to allow editing. The code below, called by the “Item Status Changed” event of “lstStudents”, handles the data retrieval and is activated when the user selects a student from “lstStudents”.
sub StudentMainGetSelected(pEvent as objoct) '### Called from lstStudent item status changed event' '### when student is selected.' '### resets code in lstClasses to show classes for this student and' '### fills frmStudentSelect ready for edits' dim oCtl, oFrm as object dim sSQL as string '### set global var to selected student ID' oFrm = pEvent.source.model.parent gCurrentStudent = pEvent.source.model.getCurrentValue() '### now get classes for this student into listbox on subform' oFrm = oFrm.getbyName("sfClasses") oCtl = oFrm.getByName("lstClasses") sSQL = "Select ""ClassInfo"", ""StudentID"", ""ClassDate"" from qryClassLangDate where" sSQL = sSQL &" ""StudentID"" = " & gCurrentStudent & " ORDER BY ""ClassDate"" DESC" oCtl.listsource = array(sSQL) oCtl.refresh() '### and finally fill the individual student detail' oFrm = pEvent.source.model.parent.parent.getbyname("frmStudentSelect") sSQL = " ""StudentID"" = " & gCurrentStudent oFrm.Filter = sSQL oFrm.ApplyFilter = TRUE oFrm.reload end sub
The same code is run when the StudentMainLoad, called from the form “When Loading” event, macro runs as it sets the selected item of the listbox.
sub StudentMainLoad(pEvent as object) '### Called when loading frmStudList' '### Click into listbox to set first student' dim oCtl, oFld as object oFld = pEvent.source.getByName("lstStudents") oCtl = ThisComponent.getCurrentController() oCtl.getControl(oFld).selectItemPos(1, TRUE) wait 100 end sub
When first loaded I can edit the fields in the Detail form (frmStudentSelect) as expected. As many edits as I like, any field, save edits and all is well.
Selecting another student from the listbox does the expected thing of showing the classes linked to that student and putting their details into the relevant place ready for editing.
as soon as I click into any of the fields in the detail form I get an error message “Error updating the current record”. Clicking on ‘More’ informs me that there is an “SQL Status of HY000, No values were modified”.
The searches I have done point to a lost DB connection but that cannot be the case, I am able to happily click away and see the relevant data for each student I click on. Just that I can’t edit them after I have clicked the listbox to invoke tha same code that ran when the form loaded!
Any pointers as to what I have got wrong here?
I have tried editing the “StudentMainLoad” macro to start on different students (i.e. not just the first entry) but the same thing happens. Also, if I click on the first student in the list before editing I get the error. It’s clear that something different is happening, I just can’t see what…
Searches reveal nothing more than that HY000 is apparently a CLI specific error???
This is a learning project for me - there is a lot of unused ‘playing around’ code to be ignored as I am gaining an understanding of how UNO works!
There are three forms in the DB:
zfrm_StudtMain is my original form which worked BUT intermittently the listbox of students will grey out, refusing to repond to clicks. Maybe in a code loop somewhere, I put it down to my lack of understanding of what I was doing.
frm_StudentMain is the form I am referring to here.I created it in the form wizard then replaced the grid control with a listbox. From there I couldn’t get the links to work hence the code…
zqryStudentSummary is one that I knocked together this morning using a slightly different form model. It worked until I put in the list box which then either shows greyed out or the form doesn’t respond to it being clicked.
I’m sure this is something simple that I have done (or not done) due to my lack of experience with LO, but my testing shows that problems arise when I try to replace the grid control with a listbox…