Topic: Script to open a form to a specific record

Hello.
I've searched the forum but have been unable to find how to open a form to a specific record using a script. I have the id, I just want to do something like FormName.Show(id of the record I want to see on screen). Any help appreciated. Thanks.

Re: Script to open a form to a specific record

Attached is a possible solution. Not sure if it will fit your scenario, but it's one way to accomplish what you are looking for.

Post's attachments

Attachment icon Open Form Specific Record.zip 581.98 kb, 568 downloads since 2016-12-08 

Re: Script to open a form to a specific record

clyde wrote:

Hello.
I've searched the forum but have been unable to find how to open a form to a specific record using a script. I have the id, I just want to do something like FormName.Show(id of the record I want to see on screen). Any help appreciated. Thanks.

Hello.


Please download latest beta version
http://myvisualdatabase.com/forum/viewtopic.php?id=2888


I have added method for form

Form2.ShowRecord('tablename', 1);

and


ShowRecord(Form2, 'tablename', 1); 
Dmitry.

Re: Script to open a form to a specific record

Hello Clyde, EHWagner, Dmitry,
As you can see already from EH and Dmitry, there are a couple of ways of doing it.
I like to keep to 'standard' MVD as much as possible so I think I'd probably use a hidden tablegrid to retrieve the record details and then call a second form on which editing can be done.  It certainly keeps the script short!
Attached is an example and hopefully it gives you more ideas/options.
Derek.

Post's attachments

Attachment icon clyde two forms.zip 337.67 kb, 637 downloads since 2016-12-08 

Re: Script to open a form to a specific record

Interesting concept Derek. I like it. Very creative and less script.


Thank you Dimitry for adding the method to the next version.

Re: Script to open a form to a specific record

Hello Again,
Realised that in my earlier post, I hadn't set form1.button2 (the 'GO' button) as default which meant you had to either click it or use 'TAB' and then 'ENTER';  now as soon as you enter the ID, you can press 'ENTER' and off it goes.  Sorry about that.
In the attachment, I've also used a slightly different approach - what I call 'form cloning' (I'm sure there must be a more technical term - LOL!).  It appears as if you are working on the same form but in fact you are flipping between the two.  As I see it, there are a number of advantages:
1.  it's still standard MVD so there is little scripting (if any) to do.
2.  you can designate different buttons as 'default' on each screen which speeds the user up.
3.  you can set what fields are enabled/disabled using object properties (again, standard MVD) rather than switching them on and off by script.
Not saying any approach is right or wrong - just shows how flexible MVD can be.
Derek.

Post's attachments

Attachment icon clyde false one form.zip 338.41 kb, 570 downloads since 2016-12-08