[Solved] Open Form from a Query

Creating and using forms
Post Reply
sergiobernardi
Posts: 4
Joined: Tue Apr 03, 2012 9:00 am

[Solved] Open Form from a Query

Post by sergiobernardi »

I'm new to OO. Starting from a Query I created (that contains all fields), I'd like to edit a record using the Form I created. In other words, in the Query I'd like to position the cursor on a record and by pressing (a macro?) button - or even better "Enter" - open the Form (I created only one Form) with the data from that record. Is it possible? (and if so, how....?) If not from the Query, is it possible from the Table View?
Thanks! Sergio
Last edited by sergiobernardi on Tue Apr 03, 2012 5:41 pm, edited 1 time in total.
OpenOffice 3.3 Windows and Ubuntu
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Open Form from a Query

Post by Arineckaig »

Welcome to the forum.

One method worth considering is to add to your form document an extra data form based on the query that should contain a grid/table form control to display the output of the query. Then set your current data form as a sub-form to the added (main) form. The effect will be that any record selected by the cursor in the main form will automatically filter and display in the sub-form data relevant to the selected record.

Please come back if this explanation merely confuses or fails to meet your requirements.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
sergiobernardi
Posts: 4
Joined: Tue Apr 03, 2012 9:00 am

Re: Open Form from a Query

Post by sergiobernardi »

I think I was able to create what you recommended. However I have an issue - I must of course keep the table fairly short to be able to see the secondary form. Therefore I need to use the search function to input say the surname to get to the right record. But that does not work using the standard search (binocular icon or CTRL-F) function ... I realize it is not a data record search (like I have in the Table view), but a "find a replace" that does not find anything... What is the easiest way to accomplish this?

[I was reading again your comment and I think I misunderstood your intent. I guess that would do it - however I'm not clear how to create a "data form based on the query that should contain a grid/table form control". Could you point me to any example / documentation how to do that? Thank you so much for your prompt reply! Sergio]

[Actually I think my problem is slightly different. I was hoping that there is the possibility to invoke from the query (or table) view the opening of the form, passing the record id as a incoming variable. Or perhaps there is an even simpler way? Basically I'm trying to perform the function that you typically had in the host applications, where you had a list of records, you were placing an "x" next to one of them and you were getting a panel (in OO terms, the Form) with the selected record fields, in view or edit mode. Translating this approach to OO, I was thinking in the query (or table) view to place the cursor on the record, press a (macro?) button and get the Form showing the associated fields (I would be ok if it goes straight in edit mode).
Hope I'm making sense... Sorry if I misunderstood your answer.]
Last edited by RoryOF on Tue Apr 03, 2012 4:49 pm, edited 1 time in total.
Reason: Colour changed for better legibility (RoryOF, Moderator)
OpenOffice 3.3 Windows and Ubuntu
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Open Form from a Query

Post by Arineckaig »

I regret I do not understand your reply - not helped by the colour of several paragraphs. I suggest the simplest route might be for you to upload a copy of your database (with any sensitive data removed) so that members of the forum can use your actual query to construct for you a demo form document to achieve your aim.

See http://user.services.openoffice.org/en/ ... =74&t=8289 for instructions on how to attach a document.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
sergiobernardi
Posts: 4
Joined: Tue Apr 03, 2012 9:00 am

Re: Open Form from a Query

Post by sergiobernardi »

I was able to do what you recommended. Thanks a lot for your suggestion!
My issue now is different. I wish to search a record in the newly created main form (connected to the query). If I use CRTL-F I get the "Find and Replace" function which does not find anything. Reading some documentation looks like I should instead have a "Find data record" function, which does not seem to be available in Forms, but only in Tables. My question is: what is the easiest way to perform a record search within the Form view? My goal is to have a way to type e.g. the surname and get straight to the corresponding record. Thank you for your patience!
OpenOffice 3.3 Windows and Ubuntu
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Open Form from a Query

Post by Arineckaig »

sergiobernardi asked:
My question is: what is the easiest way to perform a record search within the Form view?
There is no one answer to this question as the best method depends on a number of variables. I suggest you have a look at some notes and a demonstration database that can be downloaded from:
http://dl.dropbox.com/u/10552709/FilterExamples.zip.
All of the methods in that tutorial deliberately avoid the use of macros.

In certain special situations a macro may well be suitable and I would suggest you have a look at DACM's examples to be found at:
http://user.services.openoffice.org/en/ ... 00&t=42845.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
sergiobernardi
Posts: 4
Joined: Tue Apr 03, 2012 9:00 am

Re: Open Form from a Query

Post by sergiobernardi »

Thank you! This is excellent!!!
OpenOffice 3.3 Windows and Ubuntu
Post Reply