Query two tables and use as main form with sub form

Creating and using forms

Query two tables and use as main form with sub form

Postby mattheww » Thu Jul 04, 2019 5:29 pm

Hi there

This is a query and form question...
I am building a simple DB for recording pitches I make to potential clients - I have tblBusinesses (business name, details) with one to many relationship with tblContacts (contact name and details), which has a one to many relationship with tbl Pitches

I have a form for entering new Business and/or Contact.

I need a form to enter a new pitch in tblPitches with the right combination of Business and Contact searched and pre-populated, then I'll enter Pitch detail beneath that.

How do I create that second form so I can select the Business then select Contact (remember one Business might have many Contacts) to then enter the new Pitch information?

(I would have two sub forms on the first form but I don't think this is possible?

Many thanks for your help
Matthew
Open Office on 4.1.6 running on Mac OS Mojave 10.14.4
mattheww
 
Posts: 2
Joined: Thu Jul 04, 2019 5:12 pm

Re: Query two tables and use as main form with sub form

Postby Villeroy » Thu Jul 04, 2019 7:45 pm

Get toolbar "Form Design" while in form design mode. Button #5 pops up the form navigator which shows the hierarchy of forms with all subforms and controls. Unfortunately, it does not show the controls which represent a column within a table control. Anyhow, right-click the root element "Forms" to enter a new independent form or right-click an existing form to add a subform to that form. This way you can build arbitrary complex trees of forms and subforms.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28431
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Query two tables and use as main form with sub form

Postby mattheww » Thu Jul 04, 2019 8:45 pm

Thanks for reply.

Not sure what this is: Button #5
Or this: "root element "Forms"

Could you clarify what you mean please>
Open Office on 4.1.6 running on Mac OS Mojave 10.14.4
mattheww
 
Posts: 2
Joined: Thu Jul 04, 2019 5:12 pm

Re: Query two tables and use as main form with sub form

Postby Villeroy » Fri Jul 05, 2019 11:30 am

Push the 5th button on that toolbar and see.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28431
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Query two tables and use as main form with sub form

Postby UnklDonald418 » Fri Jul 05, 2019 7:13 pm

In the Forms area of the main database window right click on the name of the form document you created and select Edit.
The form document will open in the Design Mode
Along the bottom of the window should be the Form Design toolbar (it can be toggled on and off using the menu selection View>Toolbars>Form Design).
Hover the mouse cursor over those icons to see a little pop-up telling the name of that icon.
Beginning at the left which is Select move over to the right and select the one that displays Form Navigator (Using OO it is usually the 4th from the left or 5th when using LO).
A Form Navigator dialog will appear showing the tree structure of your form document.
At the very root is Forms. Right click on that and select New>Form to add a another top level form.
If you used the Form Design Wizard the first level under Forms will be MainForm. Right click MainForm and select New>Form to add a another SubForm.
You can also right click on the existing SubForm and select New>Form to add a form at the SubSubForm level (you can go as deep as you need)
Right click on any of those MainForm, SubForm, SubSubForm and select Properties to open the Form Properties dialog.
On the Data tab you can choose a Content type (Table, Query, SQL command) and Content (the name of an existing Table, or Query or even design a custom SQL query).


If two dialog lines appear on the Data tab, Link master fields and Link slave fields then you are on a subform level or below and you must chose the proper fields to tie this form to the one a level above, usually based on your designed Foreign Key, Primary Key relationships.

In your case it sounds like Business will be on the MainForm level and Contacts will be on the SubForm level and Pitches would likely be on a SubSubForm level. Then you could display one Business with many Contacts and for each Contact, many Pitches.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1322
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Query two tables and use as main form with sub form

Postby Yumi » Wed Jul 10, 2019 1:24 pm

Yes, I am able to create a new Form in the Form Navigator as you describe. But that form would not display in a separate window - or could it?
OOo 4.1.6 on Linux Mint 19.1 Tessa
Yumi
 
Posts: 26
Joined: Fri Aug 29, 2008 3:54 am

Re: Query two tables and use as main form with sub form

Postby UnklDonald418 » Wed Jul 10, 2019 10:56 pm

The Form Navigator allows you to add mulitple Forms (data sources) to a form document, but each form document has a single page. A form document is really a special type of Writer document with database controls so while it might be possible to add more Forms and controls than will fit on the screen the requisite scrolling can be confusing.
Rather than having everything on a single form document sometimes it is advantageous to have more than one. For instance one form document for entering/editing client data and another form document for entering/editing transactions and perhaps a third for display only, no editing allowed.
There is another approach where on one form document you make selection(s) that are saved in a Filter table. Then another form document can use what is stored in the Filter table to narrow the available data for it's Forms, giving the illusion of a MainForm in one form document and a SubForm in another.

Dialogs can have multiple pages (i.e. the Form Design Wizard or the Copy table dialog) but that is an advanced topic, requiring significant macro programming skills and knowledge of the OO API.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1322
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA


Return to Forms

Who is online

Users browsing this forum: No registered users and 1 guest