Replacing numeric foreign key with dropdown in Libreoffice Base - postgresql

I'm building a form for entering credit/debit transactions, so I have two tables in PostgreSQL
accounts
id INTEGER PRIMARY KEY
name VARCHAR(128)
ledger
id INTEGER PRIMARY KEY
credit INTEGER NOT NULL REFERENCES accounts
debit INTEGER NOT NULL REFERENCES accounts
date DATE NOT NULL
amount NUMERIC(8,2)
text VARCHAR(128)
I have built a form with a single table control, listing accounts.name, and a subform that references that control for selection.
Inside the subform, there is another table control, showing date, credit, text and amount after matching debit against the selected entry in the master.
So far, that works, however the credit column has the numeric foreign key data inside a numeric field. I'd like to have a dropdown field that allows me to select an account in its place.
Is that possible, or should I go for a fallback solution with a readonly table populated from a query, and separate edit fields in a subsubform?

The functionality that works in LibreOffice is a listbox. What is tricky is that the individual fields on the grid/table control are not displayed in the form navigator. However, you can convert the type of field on the grid to a listbox by going to edit mode and right-mouse clicking on the header row/column selector of the grid. In the dropdown menu, select "replace with" and "list box". Now that field/column in the grid is a list box.
Then open the "control" dialog and click again on the appropriate header/column selector in the grid, which you just changed to a listbox. Go to the "data" tab. Under "type of list contents" select "Table" and "List content" select the foreign key table. With the "bound field" having a value of "1", the dropdown list will display the first column of the list source, and it will use the value of the second column to populate the data source displayed in the listbox control.
For a better aesthetic, in the control box, "General" tab, "Dropdown" option select "Yes".
The steps above will provide a functionality mostly indistinguishable in the UI from a familiar combobox. You also can try the "combobox" functionality directly in LO, but support for that field type is not as strong.

Related

ms-access: edit form entries using foreign keys

To keep it simple there is the following table relation in ms-access: T_Create (n:1) T_Employee [foreign key is CR_Employee which contains the EM_ID)
The tables look like this:
T_Create (CR_ID, CR_Employee)
T_Employee (EM_ID, EM_Name)
To show the EM_Name field for my T_Create entries I create a query that joins on T_Employee and gets the field EM_Name. So I receive a list that contains the entries of the T_Create table with the fields CR_ID and EM_Name.
I created a form with help of the query. I want to be able to edit the entries with a dropdown menu and save it in the table T_Create. I know how it works, when I display the CR_Employee foreign key field. But I want to change the value without using this field. The form should update the foreign key in the background. In the form I want to use the text that is linked to the foreign key.
You want combobox to save the EM_ID but display the EM_Name? Use a multi-column combobox.
RowSource: SELECT EM_ID, EM_Name FROM T_Employee
ColumnCount: 2
ColumnWidths: 0";1"
BoundColumn: 1
ControlSource: CR_Employee
BTW, name parts should be in separate fields like: FName, LName, MName. Then RowSource could be: SELECT EM_ID, LName & ", " & FName AS FName FROM T_Employee;.
No need to include T_Employee in the form RecordSource unless there are more fields you want to display, such as address info. If you do include T_Employee table then set any controls bound to its fields as Locked Yes and TabStop No.

Insert text when new related field added filemaker 11

I have been tasked with adding some functionality to an old Filemaker 11 Database.
I have a table with a portal to a related field. Whenever an entry is added to the portal I am to insert some text into description field to prompt users to record some specific information related to that portal field.
I have set up some global variables to hold the required text and in the case of a normal field it is quite easy to trigger the text insert based on the value in a field. What I am having trouble figuring out is how to trigger the insert text based on the values in a portal.
Suggestions?
In general, you can insert a default value into a field by using the field's auto-enter options. If you want this to happen only upon record's creation, leave the Do not replace existing value (if any) option checked.
I did not understand this part:
how to trigger the insert text based on the values in a portal.
You need to explain how exactly the inserted text should be "based on the values in a portal".

Combobox governing subform possibly updating tables

I have a form, the form is bound to a query which returns only one field. On that form is one combo box, bound to the field from the query, a subform object and some other unimportant stuff. The Master-Child relationship between the Form and Subform is set to that same field. The intent is that dropping down the combo box allows me to add information on the subform pertaining to that record in the combobox (it's a list of classes in a school, for context). This is done through a form and subform as I have various different tasks that need to be done for each class - the intent is to be able to select a class on the main form and then use command buttons on it to select which subform is opened depending on which task I wish to perform.
However, the Combo box appears to be trying to update a table - I'm not sure which one as the error message isn't specific:
The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key or
relationship. Change the data in the field or fields that contain
duplicate data, remove the index or redefine the index to allow
duplicate values and try again
appears if I select any value other than the first one from the combo box and then click in the first text box on the subform. However, I can click in the subform with the first entry in the combo box selected and add data successfully, I've checked and it is appearing in the underlying tables.
It seems to me, as a relative novice in Access, that the combo box is attempting to update the underlying data source when it is changed, though it has no macros. I would assume there are items in the properties of the form or the combobox that prevent that from happening but I can't find them. That is just a guess as to what's happening, though, and I could be wrong.
It's possible that this is related to this question but I could be mistaken there as well. Regardless, the Form shouldn't be able to update/edit/add records but if I set Allow Edits in its properties to "No" I am unable to actually select a value from the combobox - I have set the other "Allow" properties to "No" without a problem.
If you change anything in the main form and then click on the subform then Access will try to save the data in the main form automatically. Maybe you can try to temporally exchange the combo box with a text field for testing. That should help you to clarify the problem.

MS Access form -> Combox used to filter other combobox results

I have a dropdown combo box in a form for a "Project_ID" called: Combo28 (this is the primary key basically). There are also 5 other "Error_Code" combo boxes called: cboErrCod1, cboErrCod2, cboErrCod3, cboErrCod4, cboErrCod5.
I'm looking to create some sort of "On Change" code that will only display the Error Codes pertaining to the Project_ID selected in the Combo box "Combo28" only.
The error codes are stored in a separate table and each code is associate to a particular project_Id.
Can anyone help?
I'm not sure why you have exactly five error code comboboxes. To do this easily and let access do all the work for you, you could either:
A: Have a parent form containing the dropdown for project_ID. Create a subform (continuous form view). Set the recordsource to your error codes and Link to Master using Project_ID
B: Create a subform with the recordsource "Select ErrorCodes from yourTable WHERE Project_ID = [Forms]![yourForm]![combo28] Where combo28 is your project_ID. In the after update event for your combobox, call .requery and perhaps .refresh on your subform.

MS-Access, form to view one entry from one to many relationship

I have a table with Orders and a subtable with itemId's (one to many relationship)
In the form i have a Combobox to select a specific Order and another Combobox to select a specific itemId.
For this i have made a Query to view all aviable itemId's in the second Combobox.
I dont know how to view the selected itemId-data in the form.
You can use the Where argument of the Openform action to specify the item.
OpenForm FormName, , , "ItemID=" & ComboName
-- http://msdn.microsoft.com/en-us/library/aa141520(v=office.10).aspx
This assumes that the bound column of the combo is a numeric ID that relates to an ID in the form to be opened.