| View previous topic :: View next topic |
| Author |
Message |
Ewald OOo Advocate


Joined: 16 Dec 2005 Posts: 392
|
Posted: Sun Jul 22, 2012 12:58 am Post subject: select a particular record based on list box entry |
|
|
I am working on a databse for a school environment to track students achievements. I'd like teachers to be able to select the record of a certain student.
I thought the way to do this would be using a list box. The form is based on the student table has controls for student picture, first name and last name and has a list box displaying a drop down list with all available students. The teacher selects the desired student and the form displays the corresponding picture, first and last name.
I can't figure out, however how to do that. I can create the list box and populate it with the desired data but I can't figure out how to select the corresponding record from the student table based on the list box selection.
Thus my questions:
1. Is my approach reasonable or is there a much better way to do this?
2. If the approach is reasonable, how to I select the record from the student table based on the list box selection? |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jul 22, 2012 6:43 am Post subject: |
|
|
Hello
As far I understand your problem you have to change a little your idea how to do it.
Make one table what can contain a value for the student you need.
Make one form what links to this table.
Make one listbox what is in this form and stores the data to this table. The form must not cycle to other records.
Make a subform with slave and master fields.
I more detailed version you can find here
http://user.services.openoffice.org/en/forum/viewtopic.php?f=100&t=42845
Romke _________________ OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum |
|
| Back to top |
|
 |
Ewald OOo Advocate


Joined: 16 Dec 2005 Posts: 392
|
Posted: Mon Jul 23, 2012 1:33 am Post subject: |
|
|
Thanks a lot for the reply. I used the link you pointed me to and made good progress.
I have the correct form-subform hierarchy to get what I want. What I would need still is a way to have the table control in the subform going to "new record" upon opening. I guess that would have to be achieved using macro code. Am I right? |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Mon Jul 23, 2012 7:54 am Post subject: |
|
|
Hello
Sorry your problem is not clear to me.
I think the best way is read examples of Villeroy, Arineckaig and DACM.
I think avoid macros.
Maybe you should select the data in an other way then you do now. Maybe you should start with groups and years and then students.
When you want select only one student I think your subform must show only one student no more.
Use the other forum there you can work with example.
I'm a bad database designer for that reason I always point to other people. I think the best way is forget macros and try to understand what you can do with forms and SQL. Forms are for displaysing the result of SQL. Try to build a form it the way you can easy select the data and also modify the data you want modify. I have learn to build views for showing and selecting the data in forms. I use queries built on one table for forms who I need to modify..
For this you need to understand how the forms and the controls are working. Placing the controls in the good form is real important. When you change from data-form in your form-doc your data is stored when did have changed it. Most of the time your subform is maybe also reload but this can be done with a button. You need to knew all this things also when you want work with macros. For most people it is difficult enough to understand only the forms and SQL.
Working in this way with the forms, the controls and also SQL is nearly programming.
Romke _________________ OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum |
|
| Back to top |
|
 |
Arineckaig OOo Advocate

Joined: 01 Mar 2004 Posts: 332
|
Posted: Mon Jul 23, 2012 11:56 pm Post subject: |
|
|
| Quote: | | The teacher selects the desired student and the form displays the corresponding picture, first and last name. |
In Base a list box is essentially a form control designed to enter or edit data in the field to which the list box is 'bound'. Thus, it is not well suited for filtering record-sets.
One simple way to achieve your aim would be to add a data form with a grid/table control to display a list of the student name(s) and then make your current form a sub-form to this new extra form. In Base the selection of a record in a parent form should automatically filter the record-set displayed in its linked sub-form according to the values of the matching fields set in the master and slave link fields of the sub-form.
A very simple demo file to demonstrate this method can be downloaded from:
http://dl.dropbox.com/u/10552709/Indexed-Subforms.odb
where the first form doument "1. Indexed Contacts" may well be applicable.
Please come back if you have any problems or futher questions. _________________ When this issue has been resolved, it helps other users of the forum if you add the word [Solved] to the Subject line of your 1st post (edit button top right).
OOo 3.4.1 and MySQL on MS Windows XP and Ubuntu |
|
| Back to top |
|
 |
|