Topic: Procedure ShowRecord

I might be dumb but I am struggling to use the procedure ShowRecord to actually work, whichever way I am trying, I get an error ')' expected at... or undeclared identifier: 'Users' at...

How do you write this procedure to display the record of say table 'Users' with the ID of the current form into another form the same way a button "Show Record" does?

Currently, I am trying to achieve this:

procedure Admin_UsrInfoBtton_OnClick (Sender: TObject);
begin
UserInfo.ShowRecord(Users,+Admin.User_ID.dbItem);
end;

The reason I want to script it is because I want to use an image instead of an ugly Windows button.

Re: Procedure ShowRecord

Hi,
Have you tried changing the button style to 'bscommandlink' - you can then use images as de-facto buttons without needing any script.
Derek.

Re: Procedure ShowRecord

I have tried that but there is an ugly arrow showing through. It does the trick for now but I really would like to use the script feature and the documentation is... slim.

Re: Procedure ShowRecord

Hi,
Yes, I know what you mean about the ugly arrow - sometimes you can choose images that make it less noticeable but it's annoying that you can't completely get rid of it.
Another option is to use images and link them to hidden buttons rather than actually trying to code for 'newrecord' actions or 'deleterecord' actions etc (see attachment).
Optionally, you can also 'nudge' your images so that it replicates the 'down' and 'up' movement of a button being clicked (not in the attachment). 
Also, you could change the cursor from 'crdefault' to 'crhandpoint' when the mouse hovers over the image to perhaps make it a bit more intuitive for the user.
Regards,
Derek.

Post's attachments

Attachment icon image button.zip 537.96 kb, 94 downloads since 2023-09-06 

Re: Procedure ShowRecord

That's a clever way of doing it. I do a change of color/hue/saturation on MouseEnter and MouseLeave for my actionnable images, it's the same a passing by a button and I have your example for the "nudging". Thanks a lot Derek.

Re: Procedure ShowRecord

Changing color/hue as you mouse enter / leave is a nice touch - I'll give that a try.
A different option again is to use unicode symbols (or combinations of unicode symbols and plain text).  Because it's just a caption to the button it can be done very simply with no script at all (example attached).
Unfortunately, they are all monochrome but it can nevertheless be quite effective.
Derek.

Post's attachments

Attachment icon image button.zip 435.58 kb, 84 downloads since 2023-09-07 

Re: Procedure ShowRecord

Hi all


Something like this

Post's attachments

Attachment icon image button upd.zip 425.58 kb, 95 downloads since 2023-09-07 

Re: Procedure ShowRecord

Hi Sparrow,

any comment about this? What are the options for styleelements?:

form1.button1.styleelements := 2;

Re: Procedure ShowRecord

The book is the best source of knowledge.
Or Google...
)))

Re: Procedure ShowRecord

Which book??

Re: Procedure ShowRecord

I understand why colleagues are interested this book: such a trick looks like a hack)))

Визуальное программирование: блог и телеграм-канал.

Re: Procedure ShowRecord

Are you referring to this: => https://k245.ru/mvdb/non-code-prilozheniya-mvdb.html

It's great, lots of missing details from Dmitry's help file but not really easy for non Cyrillic readers as some texts are not translated at all by the auto translate features of our web browser!! wink

Below is copy paste from web browser after auto translate of this page : https://k245.ru/mvdb/otobrazhenie-tabli … annyh.html


WantTabs    Reaction to Tab    Determines the reaction of the component to pressing the <Tai> key. If the property is set to True, tabulation symbols are inserted into the text when the <THAT> key is pressed. By default, the WantTabs property is set to False, and when you press the <Tah> key, the table sends input focus to the next window control.

TabLeaveControl*    Loss of focus with the <Tab key    Determines whether the component will lose input focus when you press Tab

Хотите Возвраты*    Enable line feed with the Enter key    Determines whether multiline text will be allowed when you press Enter

Иинкрем, поиск    "SEARCH" button    A table can act as a filtering management tool if it is specified as a data source when configuring a button with the [SEARCH] action. In order for filtering to change synchronously with moving through the rows of the table, specify the button responsible for searching the data in this property.

Re: Procedure ShowRecord

k245 wrote:

I understand why colleagues are interested this book: such a trick looks like a hack)))


well why at once hack? This is a perfectly legal way to style.
It's just not widely publicized. The description is present in the Embarcadero.
That's just not for all cases and not for all elements.
I remember a post about creating a table dynamically where the style doesn't get there. )))

Re: Procedure ShowRecord

tcoton wrote:

Are you referring to this: => https://k245.ru/mvdb/non-code-prilozheniya-mvdb.html

It's great, lots of missing details from Dmitry's help file but not really easy for non Cyrillic readers as some texts are not translated at all by the auto translate features of our web browser!! wink

Below is copy paste from web browser after auto translate of this page : https://k245.ru/mvdb/otobrazhenie-tabli … annyh.html


WantTabs    Reaction to Tab    Determines the reaction of the component to pressing the <Tai> key. If the property is set to True, tabulation symbols are inserted into the text when the <THAT> key is pressed. By default, the WantTabs property is set to False, and when you press the <Tah> key, the table sends input focus to the next window control.

TabLeaveControl*    Loss of focus with the <Tab key    Determines whether the component will lose input focus when you press Tab

Хотите Возвраты*    Enable line feed with the Enter key    Determines whether multiline text will be allowed when you press Enter

Иинкрем, поиск    "SEARCH" button    A table can act as a filtering management tool if it is specified as a data source when configuring a button with the [SEARCH] action. In order for filtering to change synchronously with moving through the rows of the table, specify the button responsible for searching the data in this property.

Colleagues, please be patient. Once I have completely transferred the contents of the beginner's tutorial to hyperbook format, I will translate it into English. Now there are many clarifications, additions and corrections to these materials, so English-speaking readers will be more lucky - they will immediately receive better information. But a little later.

Визуальное программирование: блог и телеграм-канал.

Re: Procedure ShowRecord

sparrow wrote:
k245 wrote:

I understand why colleagues are interested this book: such a trick looks like a hack)))


well why at once hack? This is a perfectly legal way to style.
It's just not widely publicized. The description is present in the Embarcadero.
That's just not for all cases and not for all elements.
I remember a post about creating a table dynamically where the style doesn't get there. )))

Be that as it may, your find is very valuable and can significantly diversify the user interface. Combinations of style and color for buttons, images on which are created by UNICODE characters - this is a great solution!

Визуальное программирование: блог и телеграм-канал.

Re: Procedure ShowRecord

k245 wrote:

Colleagues, please be patient. Once I have completely transferred the contents of the beginner's tutorial to hyperbook format, I will translate it into English. Now there are many clarifications, additions and corrections to these materials, so English-speaking readers will be more lucky - they will immediately receive better information. But a little later.


Keep up the good work, I cannot wait to see the scripting section with all the possibilities that we don’t even know yet!

Re: Procedure ShowRecord

So this is what you are waiting for. All combinations and secrets in one book?

Re: Procedure ShowRecord

sparrow wrote:

So this is what you are waiting for. All combinations and secrets in one book?

Not really, but at least it ressembles something more of a user manual that never existed in the first place than a book of all secrets!!
Most of the time, I look on the internet in different places including this very forum before asking here.

Look, nobody can answer to the question of my post!! Good example of missing documentation if you ask me!! wink

Re: Procedure ShowRecord

Hi Thierry,
To answer the question in your original post (about using an image instead of a button), when you click on your 'edit record' image, try it like this

form2.ShowRecord('yourtablename',form1.tablegrid1.dbitemid)

And for a new record, when you click on your 'new record' image, try it like this

form2.NewRecord('yourtablename',-1)

And for a deletion, when you click on your 'delete record' image, try it like this

sqlexecute('delete from companies where id = "'+form1.tablegrid1.sqlvalue+'"');
form1.tablegrid1.dbupdate;

Derek.

Re: Procedure ShowRecord

Thank you so much Derek, the contextual help was completely wrong for the syntax of "ShowRecord", you got it! The dbItemID also works with a Combobox.

Re: Procedure ShowRecord

I don't know what you're looking for or where you're looking for it.
Here is a link to the documentation http://myvisualdatabase.com/help_en/script_form.html,
and here is what you asked about.

procedure NewRecord (ParentTable: string = ''; ParentTableID: integer = -1)
 Prepares and shows the form on the screen for creating a new record. Similarly, if the forms were called by the button with the "New Record" action.

procedure ShowRecord (TableName: string; id: integer)
 Displays a form with data from the database for the specified record.

How do you like this?

22 (edited by CDB 2023-09-09 22:31:54)

Re: Procedure ShowRecord

sparrow wrote:

I
How do you like this?

I think Sparrow, where tcoton was having difficulty, was in trying to work out how to get an Image Click to do what a Button Click can do either by script or from the inbuilt functions for ShowRecord etc.

On a clear disk you can seek forever

Re: Procedure ShowRecord

sparrow wrote:

I don't know what you're looking for or where you're looking for it.
Here is a link to the documentation http://myvisualdatabase.com/help_en/script_form.html,
and here is what you asked about.

procedure NewRecord (ParentTable: string = ''; ParentTableID: integer = -1)
 Prepares and shows the form on the screen for creating a new record. Similarly, if the forms were called by the button with the "New Record" action.

procedure ShowRecord (TableName: string; id: integer)
 Displays a form with data from the database for the specified record.

How do you like this?

I think you are over reacting to my initial question that has been answered by Derek and if you look closely to his answer, you will see how and why I was confused by the “documentation” and the actual way of using it.

Re: Procedure ShowRecord

CDB wrote:
sparrow wrote:

I
How do you like this?

I think Sparrow, where tcoton was having difficulty, was in trying to work out how to get an Image Click to do what a Button Click can do either by script or from the inbuilt functions for ShowRecord etc.


Not exactly, I was actually struggling to use the function “ShowRecord” with the proper syntax in a script which is :
form_where_the_record_will_show.ShowRecord(‘tablename’, form_containing_the_record_ID.tablegrid_or_combobox.dbitemID);

What is missing in the “documentation” is the actual syntax for each function, not everyone is an experienced developer.