Macro to open a form showing all information of selected item

ListBoxFilter_withPushButton.odb (749.7 KB)
I took the liberty of using Renel LOB “ListboxFilter.odb”, which seems to be working quite well, to exemplify my need to create a new macro that allows me to open a form showing a specific record of the table in which it is based.

I created a new form “FrmFilms” to enter and view all the records from the main table “TFilmsSeries”, which may have an undetermined number of fields (or columns).

And I created an action button on the “FilmsSeries” form, to open “FrmFilms” in the selected record, whose “FilmSerieID” record from the “TfilmsSeries” table corresponds to the value of the “fmt-IDFilmSerie” field of the “FilmSeries” form.

In other words: this database allows me to select a letter and list all the movie names that start with that letter. This is great, but not enough!

Now, with the list of film names organized alphabetically, starting by the letter I chossed, I want to open the form I created “FrmFilms” and see all the information about the film I selected.

If you open the form “FilmsSeries”, you’ll see a yellow action button “OpenFilm”. What I need to create is a macro for that button to open the form “FrmFilms” showing all the information of the selected film.

My question is: Is this possible? Can somebody help me? Thanks in advance.

Yes. Start with this thread, wich was begun 3 days ago.

Here
Base Macro - Click on Table Row to Open Record
there is a sample DB: OpenFormFromGridSelection.odb
from @Ratslinger I think will suit you.
After you set up the ordered TableControl from TFilmsSeries
CustomersGrid in sample
you should be able to open FrmFilms in the selected record
CustomersEdit in sample.
 
Take notice you don’t need form’s row as in the above mentioned thread.
You only need to open the form filtered by first letter
and in your source (for the Form) can ORDER BY < name > if you want it.
Or, better, do it all in the SQL Command for Data Source. To do this also employ the Filter Table Method

  1. Main - Filter Table where you enter your LIKE criterion;
  2. Sub Form = TFilmsSeries.

A simpler yet solution with pop-up for the first letter.
Afterwards you could proceed with @Ratslinger solution.
Form’s source:

SELECT "FilmSerieID", "TitreAnglais1" FROM "TFilmsSeries" 
WHERE UPPER ( "TitreAnglais1" ) LIKE UPPER ( :Primeira_Letra ) || '%' 
ORDER BY UPPER ( "TitreAnglais1" )

 
ByFirstLetter
Parameter

@Quaresma,
you only have 1 table and therefore it would be simple to add all fields (controls) to your existing form.
I guess that does not appeal.
an alternative which may suit is to show or hide those controls at a whim.
.
I split your table into 2 tables.
the film info can be shown/hidden by button click.
I added 2 macros ‘ToggleFilmInfo’ and ‘RefreshLettersListBox’.
.
there is an obvious omission in the original code:
when a film is added, updated or deleted which results in zero entries beginning with that letter
or
a new entry which begins with a previously unused letter i.e. ‘Zulu’ (Z)
then
the letters list box was not refreshed.
the macro ‘RefreshLettersListBox’ fixes this.
.
I had an issue when using the original navigation bar, after an image was added/replaced the navigation bar would not reappear when the ‘Film & Series’ form was reselected, the solution was to use a form navigator control.
.
I inserted 2 dummy records for testing, film names ‘DUMMY_1’ and ‘DUMMY_2’.
although not included I did test with external images without issue, to insert an image just right click on the image control and select ‘Insert image from’.
Quaresma_Films.odb (121.9 KB)

1 Like

Thank you very much for your excellent help. It seems to be working perfectly and is in line with my goals. I will carefully study all the developments to learn from those who know. Thank you very much.

Thank you for your quick response and for the time and effort you spent trying to help me solve my problem. Best regards. Thank you.