Macro for Form: Update & Display Data in Listbox subform
Posted: Sat Sep 10, 2022 3:00 pm
Hello,
I have Openoffice on a Win10 platform. I have looked at previous Forum postings on the subject of creating search forms and making them work, and I understand that in order to do what I want for my project I need to have at least one macro.
It is a long time since I worked with databases (1980’s Oracle Ver 4 & 5), so I need a lot of help with macros.
The nearest to what I want to do seems to be https://forum.openoffice.org/en/forum/v ... +filtering . I tried loading the autors sample database and hunted round that but couldn’t find anything useful to me. I still have no idea how to create the macro or where to put it because the author seems to assume the reader has greater knowledge than I have.
What I want to do is create a database that gives a race commentator extra information about competitors when they finish e.g. Raised £3k for charity at their last race. He will use a laptop with a numeric keypad to input competitor numbers as they cross the finish line. After each number entry I expect the computer to do a query across several tables and output the folllowing information: Race Number/Competitor Name/Race Distance/Competitor Club/Previous History e.g. raised money for charity, or finished 2nd in previous weeks race.
I have created three tables:
Entries:
Field Names: ID, RaceNum, Fname (First Name), Sname (Surname), Teamname, RaceDist, Gender, Age & Cat
History:
Field Names: ID, Fname, Sname, Teamname, History, Gender, Age & Cat
Order_of_Finish:
Field Names: ID <Autofield> & CompNum (initially left blank)
I have created one Query:
Finish_History:
Order_of_Finish.CompNum is Inner Joined to Entries.RaceNum
Entries.Fname is Right Outer Joined to History.Fname
and Entries.Sname is Right Outer Joined to History.Sname
The result is displayed in descending order of Order_of_Finish.ID so that first finisher is in the bottom row of table and most recent finisher is in the top row of the table displayed.
I have tested the above and it all works as expected.
I then used the Form Wizard to select CompNum from Order_of_Finish table, then a subform containing all the fields of Finish_History query
I left CompNum as columnar with label above and Finish_History as a data table. I used no joins between the table and query.
The form lookd fine, but it was when I came to use the form that my problems started.
I opened the form and both fields were empty (as expected)
I moved the cursor to be in the CompNum field and clicked
I entered a valid race number and pressed enter.
For a split second the table populated with the details for the competitor associated with the valid race number, then it cleared to a blank field in both the CompNum field and the data table. In order to display the entry so that I could read it, I had to click on the back arrow symbol at the bottom of the screen.
In order to enter the next valid race number, I then had to click on the forward arrow symbol at the bottom of the screen which showed a blank field in both the CompNum field and the data table.
Again I move the cursor to be in the CompNum field and click.
Then I enter the next valid race number and press enter.
Again for a split second the table populated with the details for both the competitor associated with the valid race number and the previous competitor entered - then it cleared to a blank field in both the CompNum field and the data table. In order to display both entries I had to click on the back arrow symbol at the bottom of the screen.
For every valid race number I have to repeat the last two steps shown in black.
Some races could have as many as 700 competitors crossing the line in less than two hours, so the above is unworkable in the real world.
What I would like is to have a macro so that each time I enter the next valid race number and press enter, the CompNum field will clear to await the next entry and the table will populate and stay visible till the next number is input. When that next number is input then the table should update and again remain visible. That would make the database extremely worthwhile for the comentator using it.
Can anyone tell me please how to create that ideal macro, and more importantly where to put it and how to invoke it?
Incidentally, on my earlier tests I had a refresh button which did some of the work, but that seems to have disappeared now.
Thanks in advance.
I have Openoffice on a Win10 platform. I have looked at previous Forum postings on the subject of creating search forms and making them work, and I understand that in order to do what I want for my project I need to have at least one macro.
It is a long time since I worked with databases (1980’s Oracle Ver 4 & 5), so I need a lot of help with macros.
The nearest to what I want to do seems to be https://forum.openoffice.org/en/forum/v ... +filtering . I tried loading the autors sample database and hunted round that but couldn’t find anything useful to me. I still have no idea how to create the macro or where to put it because the author seems to assume the reader has greater knowledge than I have.
What I want to do is create a database that gives a race commentator extra information about competitors when they finish e.g. Raised £3k for charity at their last race. He will use a laptop with a numeric keypad to input competitor numbers as they cross the finish line. After each number entry I expect the computer to do a query across several tables and output the folllowing information: Race Number/Competitor Name/Race Distance/Competitor Club/Previous History e.g. raised money for charity, or finished 2nd in previous weeks race.
I have created three tables:
Entries:
Field Names: ID, RaceNum, Fname (First Name), Sname (Surname), Teamname, RaceDist, Gender, Age & Cat
History:
Field Names: ID, Fname, Sname, Teamname, History, Gender, Age & Cat
Order_of_Finish:
Field Names: ID <Autofield> & CompNum (initially left blank)
I have created one Query:
Finish_History:
Order_of_Finish.CompNum is Inner Joined to Entries.RaceNum
Entries.Fname is Right Outer Joined to History.Fname
and Entries.Sname is Right Outer Joined to History.Sname
The result is displayed in descending order of Order_of_Finish.ID so that first finisher is in the bottom row of table and most recent finisher is in the top row of the table displayed.
I have tested the above and it all works as expected.
I then used the Form Wizard to select CompNum from Order_of_Finish table, then a subform containing all the fields of Finish_History query
I left CompNum as columnar with label above and Finish_History as a data table. I used no joins between the table and query.
The form lookd fine, but it was when I came to use the form that my problems started.
I opened the form and both fields were empty (as expected)
I moved the cursor to be in the CompNum field and clicked
I entered a valid race number and pressed enter.
For a split second the table populated with the details for the competitor associated with the valid race number, then it cleared to a blank field in both the CompNum field and the data table. In order to display the entry so that I could read it, I had to click on the back arrow symbol at the bottom of the screen.
In order to enter the next valid race number, I then had to click on the forward arrow symbol at the bottom of the screen which showed a blank field in both the CompNum field and the data table.
Again I move the cursor to be in the CompNum field and click.
Then I enter the next valid race number and press enter.
Again for a split second the table populated with the details for both the competitor associated with the valid race number and the previous competitor entered - then it cleared to a blank field in both the CompNum field and the data table. In order to display both entries I had to click on the back arrow symbol at the bottom of the screen.
For every valid race number I have to repeat the last two steps shown in black.
Some races could have as many as 700 competitors crossing the line in less than two hours, so the above is unworkable in the real world.
What I would like is to have a macro so that each time I enter the next valid race number and press enter, the CompNum field will clear to await the next entry and the table will populate and stay visible till the next number is input. When that next number is input then the table should update and again remain visible. That would make the database extremely worthwhile for the comentator using it.
Can anyone tell me please how to create that ideal macro, and more importantly where to put it and how to invoke it?
Incidentally, on my earlier tests I had a refresh button which did some of the work, but that seems to have disappeared now.
Thanks in advance.