1 (edited by reteinformatica 2023-03-16 13:10:00)

Topic: Print only a record of a Table Grid

Hi everyone,
here i am again. The problem I can't solve this time is on the code to print only one selected record on a Table Grid.
As an action on clicking a button (bPrintselected) I chose "Report (SQL). The button is found in the first form (frmStart) and is the one with the writing "Print selected".
This is the code I wrote while studying the sample projects:

SELECT
Libro.record_count, Libro.Titolo, Libro.Autore,
Libro.Editore, Libro.Anno, Genere.Genere, Tipo.Tipo,
Libro.id                                                 

FROM Libro

LEFT OUTER JOIN Genere ON Genere.id=Libro.id_Genere 
LEFT OUTER JOIN Tipo ON Tipo.id=Libro.id_Tipo

WHERE Genere.id=$id
WHERE Tipo.id=$id

The highlighted errors are those of the following images. Thanks to all and a greeting.

Post's attachments

Attachment icon 3.jpg 40.53 kb, 27 downloads since 2023-03-16 

Re: Print only a record of a Table Grid

The project in attachment

Post's attachments

Attachment icon Amici della Lirica.zip 665.85 kb, 104 downloads since 2023-03-16 

3 (edited by sparrow 2023-03-16 14:11:48)

Re: Print only a record of a Table Grid

Hi


There cannot be two WHEREs in a SQL query and the condition is incorrectly defined.



Sample is good, but books (MVD, SQLite) need to be read.


SELECT
Libro.record_count, Libro.Titolo, Libro.Autore,
Libro.Editore, Libro.Anno, Genere.Genere, Tipo.Tipo,
Libro.id                                                 

FROM Libro

LEFT OUTER JOIN Genere ON Genere.id=Libro.id_Genere 
LEFT OUTER JOIN Tipo ON Tipo.id=Libro.id_Tipo

WHERE Libro.id=$id

4 (edited by sparrow 2023-03-16 15:07:02)

Re: Print only a record of a Table Grid

Project w/o Report SQL

Slightly changed.

Post's attachments

Attachment icon Amici della Lirica2.zip 678.32 kb, 90 downloads since 2023-03-16 

Re: Print only a record of a Table Grid

with sparrow's SQL solution

Post's attachments

Attachment icon Amici della Lirica2 (bis).zip 582.41 kb, 91 downloads since 2023-03-16 

Destiny

Re: Print only a record of a Table Grid

A huge thank you to both of you in particular for the two solutions with both types of reports. Knowing more never hurts.
Thanks sparrow also for the stylistic enrichments with the message boxes where I can write whatever I want.

Re: Print only a record of a Table Grid

Hello, here i am again. I would like to know if it's possible change form caption of the ShowMessage istruction. I did a lot of searches but I found no informations about ShowMessage parameters. Thank you.

Re: Print only a record of a Table Grid

Hi Fabio,
Try using 'messagebox' to give you the option of changing the message box header
There is also the option of 'messagedlg'
I was looking at your 'Amici della Lirica' probject and have made a few suggestions which might also give you some  ideas.
To explain a couple of them.
With your reports, rather than show an error message if the user tries to print something when nothing is selected, I hide the 'print' button instead (I think it's better if you can to stop an error happening rather than telling the user afterwards).  Also, the option to print multiple records stays on frm_avvio but the option to print a single record is moved to frm_inserimento (it just seemed more logical and perhaps easier for the user to understand).  And you do not need to have two separate reports - you can use the same report for multiple and single record selections.
I also put url links to your websites and to the 'Amici Della Lirica' site as well.
All the rest are just cosmetic.  Perhaps it can give you some other ideas.
Both the 'message box' application and the 'Amici' application are in the attachment.
Regards and hope the family are well,
Derek.

Post's attachments

Attachment icon fabio.zip 1.38 mb, 110 downloads since 2023-03-18 

9 (edited by reteinformatica 2023-03-18 16:39:54)

Re: Print only a record of a Table Grid

Hi Derek, I really liked your stylistic corrections and also the suggestions on what to avoid to make it more practical for the user instead of getting an error message don't make them do it. As always, your suggestions and directions are very valuable, in fact I'm getting many ideas from them.
Looking for the parameters for showmessage, I came across the messagedlg instruction but I understood that I had to write too much code, instead I saw and tried that with messagebox, in addition to writing a custom caption, you can also put warning icons and more.
As always I have to thank you so much derek and I also hope that your family are well.

Re: Print only a record of a Table Grid

Hi Derek, the GIF solution causes video artifacts in my different computer
configurations. And the solution with the button in the main form is also debatable.
I always liked your decisions to make it easier, unlike me)))

Re: Print only a record of a Table Grid

Hi derek, where can you get the symbols you put as captions in the buttons? Thank you!

Re: Print only a record of a Table Grid

Hi Fabio,
Have a look at this link
http://myvisualdatabase.com/forum/edit.php?id=46947
If you search on Google for 'unicode symbols' or 'utf symbols' you'll find many sites that have thousands of symbols.
I just collect a list of the ones that I'm likely to use and save them in a .txt file for quick access (see attached).  And as I find a new symbol that I might need, I simply add it to the .txt file.
Derek.

Post's attachments

Attachment icon common buttons.txt 155 b, 98 downloads since 2023-03-19 

13 (edited by reteinformatica 2023-03-19 17:16:08)

Re: Print only a record of a Table Grid

Thanks Derek! One more thing: how did you manage, in the beautiful project you attached, to hide the original MVD menu without writing the code:

frmStartup.mnifile.visible := false;
frmStartup.mniabout.visible := false;
frmStartup.mnioptions.visible := false;

Another thing that I find very useful from your project is that I also learned how to translate the original messageboxes with 'transalte' instruction.
I've tried doing the same with tooltip error messages for example when a field is required and nothing has been entered. Unfortunately it doesn't translate anything for me in this case.
Iput:

translate('The_Field_is_Required_Please_Enter_a_Value_for_the_Field', 'È necessario inserire qualcosa in questo campo');

Is there another way?
A thousand thanks.

Re: Print only a record of a Table Grid

Hello reteinformatica, Hello Derek

Not all messages appearing in MVD are translatable because Dmitri did not type them all.
You would have to come across this message close to the one you can't translate for it to work:
Translate('This_Field_is_required', 'your translation');

JB

Re: Print only a record of a Table Grid

Caio Fabio, Salut Jean,
The problem I was having was that I wanted to use the new 'visual styles' feature which can make your forms look a lot more modern but I also wanted to
1.  get rid of the standard MVD menu options (screen 01) which I don't like the User seeing.
2.  the menu options are easy enough to get rid of with a small script but this leaves an empty 'menu bar' at the top of the screen (screen 02) which I could find no way of removing by a script and I didn't want to start changing any visual styles files (*.vsf).
3.  Because the standard MVD menu only appears on the first form of your application and not on any of the others, I thought that by using a 'false' first form (in my example, it's call 'formfalse') and writing a small script (screen 03) to call another form and then close the 'falseform' immediately, it would solve both problems;  don't forget that the 'formfalse' tab needs to be moved to the very left of all the forms so that it becomes the first form that MVD sees when the application runs.
4.  And the result is (screen 04);  now there is no wasted space at the top of the form and you can use it for whatever you want.
5.  The only other thing to remember is to set all the other form positions to 'poScreenCenter' (why it behaves like this I have no idea!). 
Regards,
Derek.

Post's attachments

Attachment icon fabio mvd menu.zip 574.79 kb, 97 downloads since 2023-03-19 

16 (edited by reteinformatica 2023-03-19 19:53:28)

Re: Print only a record of a Table Grid

Ah now it's clear why you couldn't see the menu yet there wasn't the script.
I have one more derek request if you don't mind. Following your project I tried to apply a part to mine: the part where in the article insertion window by pressing the save button the record is saved but the article insertion window remains open to insert a new article.
So I wrote:

var new : string;

procedure frmInserimento_bSalvacontinua_OnAfterClick (Sender: TObject);
begin
  if new = 'new' then
    begin
      frmStart.bEnter.click;
      frmInsert.edTitle.setfocus;
    end else frmInsert.close;
end;

But the window closes for me. As always thank you so much Derek.
Thanks to you too Jean.Brezhonek for answering me.

Post's attachments

Attachment icon Amici della Lirica - Copia.zip 569.62 kb, 88 downloads since 2023-03-19 

Re: Print only a record of a Table Grid

Hi,
The condition to remain on 'frminserimento is nuovo = 'new' but I cannot see where you are ever setting it to 'new' in the first place.
You need to add something like this

procedure frmInserimento_OnShow (Sender: TObject; Action: string);
begin
  if action = 'NewRecord' then nuovo := 'new'
end;

Derek.

Re: Print only a record of a Table Grid

Oh thanks derek, all is clear.

Re: Print only a record of a Table Grid

Greetings all,

Nice thread!

derek wrote:

I just collect a list of the ones that I'm likely to use and save them in a .txt file for quick access (see attached).  And as I find a new symbol that I might need, I simply add it to the .txt file.
Derek.

I like the idea of the symbols for button icons.  I know this is your personal collection derek, but some of them do not render properly for me.  I am guessing these are font specific.

I tried viewing it in both Notepad2 and Notepad++ and also pasted them into Word.


Which editor do you normally use?  And would you share the settings to get them to display properly?


I also get the same result pasting them into MVD.

-joshuA

Post's attachments

Attachment icon common-buttons.png 12.98 kb, 32 downloads since 2023-03-20 

"Energy and persistence conquer all things."

Re: Print only a record of a Table Grid

Hi Josh,
I'm just using Windows 10 / Notepad with a font of Arial.  Then within my MVD application, I just leave the font for the button caption at the default 'segoe UI' (with an appropriate change to the font size)).
Not sure why some wouldn't render properly in your set-up.
Perhaps you could try re-downloading them and see if that makes any difference.
The site I use to get them is:
https://www.vertex42.com/ExcelTips/unicode-symbols.html   but there are many others.
Then I just highlight them followed by copy/paste into the .txt. file where I save them for quick reference.
Derek.

21 (edited by reteinformatica 2023-03-20 12:51:56)

Re: Print only a record of a Table Grid

Hi joshuA and derek,
I opened derek's file with Windows notepad and I even see the color characters (font: Arial). It's the first time in 30 years that I've seen color fonts in notepad, I thought it wouldn't even be possible. Maybe in the last one of Windows 11.
However you said well: it's a great idea to put the symbols like Caption.

Post's attachments

Attachment icon paint.jpg 51.08 kb, 24 downloads since 2023-03-20 

22 (edited by sparrow 2023-03-20 13:33:26)

Re: Print only a record of a Table Grid

Hi Derek, joshuA and reteinformatica

All of these characters are Unicode characters.
Characters are gradually added and this leads to the fact that new versions of Unicode
appear, with new or corrected images.

For example, the phone symbol was added in 1993 revision 1.1, and the left-facing speech
bubble character was added in 2014 revision 7.0. Therefore, if your font file or files are outdated,
some characters may not be displayed. Information about fonts and versions, depending on
the version of Windows, can be found on the Microsoft website, and the symbol and its history
of appearance are simply in Google.

Colored refers to emoji characters.

Re: Print only a record of a Table Grid

Wow, those look nice from the 10+ notepads.  That explains it because I still use Windows 7 often.


sparrow: thank you for responding-  Unicode seems to be a moving object, thanks for the extra detail.  It may be possible to update on Windows 7, haha


Thanks again
-joshuA

"Energy and persistence conquer all things."

Re: Print only a record of a Table Grid

derek wrote:

Hi Fabio,
Have a look at this link
http://myvisualdatabase.com/forum/edit.php?id=46947
If you search on Google for 'unicode symbols' or 'utf symbols' you'll find many sites that have thousands of symbols.
I just collect a list of the ones that I'm likely to use and save them in a .txt file for quick access (see attached).  And as I find a new symbol that I might need, I simply add it to the .txt file.
Derek.


Too bad, I get the error : "You do not have permission to access this page." when following your link.

Re: Print only a record of a Table Grid

Hi Tcoton,
This is usually the message you get when you try to access a link within the Forum but you aren't actually logged on.
Derek.