I have created a table Control, to show records associated with a particular relationship.
Right now, the table lists the records as first in, first listed. I would like this table control to sorted based on one column of information that I added to the table control. I added a column to the table control, to use the table's relationship to show related data from another table, and I would like to sort the table's info based on that column. Right now, this table control belongs to a subform.
Or should a query be made? And insert the query as a subform? I can do this successfully if I set link master and slave fields
sorting in Table Control
Re: sorting in Table Control
I did something like that and if my memory serves me I used a query adding the statement at the end, then I've selected the query as content for the subform.
Leaving the "evaluate SQL command" on should let you to choose the slave field from query result.
Code: Select all
ORDER BY fieldname
Leaving the "evaluate SQL command" on should let you to choose the slave field from query result.
Re: sorting in Table Control
Yep, you can order the columns and rows by using an appropriate select query.
For occasional sorting of an already loaded form you can use buttons on toolbar "Form Navigation".
Code: Select all
SELECT field3, field2, field1 FROM table ORDER BY field5 ASCENDING, field4 DESCENDING
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: sorting in Table Control
Where do I enter these sql commands?
I am using a subform. The subform enters data for each EmployeeID that participated in each JobID in the main form. The subform does have a slave/master link to the mainform. I have a table control set to display the data of the subform. The subform's table does not contain the employee last names, just ID's on jobs they worked at.
In the table control, I inserted a column and made as a listbox, and in the list box I figured out an SQL command to list the last name of employees that match their employee ID for the job. It works out that for each displayed ID in the mainform, the subform lets me enter new employees (I used a listbox to insert their ID into the subform, using a table relationship to an employee table to show their last names.) It is also convenient because I can change data in the table view. The Listbox uses this SQL to grab names from a sepaerate table. SELECT "LastName", "ExployeeID" FROM "Employees" I would like the the table to sort itself base don this inserted listbox column.
The employee names and personal info are in a different table so there is no duplication of data. I can't figure out how to get the table control to sort based on the column listbox I inserted.
I have a screenshot of the form I am working with with the separate forms drawnout - might be easier to see what I am trying to do.
http://tinyurl.com/3sj9mv
I am using a subform. The subform enters data for each EmployeeID that participated in each JobID in the main form. The subform does have a slave/master link to the mainform. I have a table control set to display the data of the subform. The subform's table does not contain the employee last names, just ID's on jobs they worked at.
In the table control, I inserted a column and made as a listbox, and in the list box I figured out an SQL command to list the last name of employees that match their employee ID for the job. It works out that for each displayed ID in the mainform, the subform lets me enter new employees (I used a listbox to insert their ID into the subform, using a table relationship to an employee table to show their last names.) It is also convenient because I can change data in the table view. The Listbox uses this SQL to grab names from a sepaerate table. SELECT "LastName", "ExployeeID" FROM "Employees" I would like the the table to sort itself base don this inserted listbox column.
The employee names and personal info are in a different table so there is no duplication of data. I can't figure out how to get the table control to sort based on the column listbox I inserted.
I have a screenshot of the form I am working with with the separate forms drawnout - might be easier to see what I am trying to do.
http://tinyurl.com/3sj9mv