Topic: What will happen if we do not use action new record

What will happen when we do not use the add new record action and instead that we will choose the action show form and fill our edit boxes and save the records? Is there any problem?

2 (edited by ehwagner 2020-05-10 16:16:58)

Re: What will happen if we do not use action new record

There should not be a problem with that, but you will need to clear the form fields on FormShow otherwise the same fields will show up on the next form show and it will duplicate the record if you do not change the field contents. I'm not sure why you would want to do this.

3 (edited by v_pozidis 2020-05-10 19:29:23)

Re: What will happen if we do not use action new record

I do not want so many forms in my project. So if  I add the edit boxes and the combo boxes with buttons of new record, edit record and delete in the same form with the tablegrid it would be great. it would be better to work in some cases in the same forms instead to open new ones.
I know you can directly wirk in the tablegid but I am not so good in SQL.
https://i.postimg.cc/NF5DbYxm/Capture.png

Re: What will happen if we do not use action new record

Hi V_Pozidis, EHW,
Not sure I understand fully your issue when you say you don't want to use the 'new record' action (or 'show record' action). 
You can still use both of these actions with the same form that your tablegrid uses.
The issue with clearing out the previous values in your edit fields, comboboxes etc is exactly as EHW has stated - otherwise it is far too easy to create duplicate entries.
Even if you clear your edit fields after saving and stay on the same form, I think it is also important to set at least one of your edit fields to be mandatory, otherwise it's very easy to accidently create empty rows as well.
Have a look at the attached which hopefully might help.
Derek.

Post's attachments

Attachment icon crud same form.zip 904.11 kb, 378 downloads since 2020-05-11 

5 (edited by ehwagner 2020-05-11 03:16:38)

Re: What will happen if we do not use action new record

derek,v_pozidis,
I was putting together a similar solution when I saw your post Derek. Not meant to step on you, but maybe it will give v_pozidis some additional ideas for his own project. My solution is very similar as yours. The only difference is that you can scroll through the tablegrid and display the record details. It's a tad bit more script, but some of it is not necessary. It just goes to show that there is more than one way to do things in MVD. The main point for v_pozidis is that you can still use NewRecord and ShowRecord on the same form as the tablegrid form.

Post's attachments

Attachment icon Same_Form.zip 338.25 kb, 325 downloads since 2020-05-11 

6 (edited by v_pozidis 2020-05-11 08:50:04)

Re: What will happen if we do not use action new record

yes i think it's much better in this way. So you do not have to create so many forms.
Thank's to all

Re: What will happen if we do not use action new record

Hi EHW,
No toes stepped on at all!  Better to have two solutions than none at all.
I like the way you use Form1.ShowRecord('Test', Form1.TableGrid1.dbItemID) to show the record rather than a hidden 'showrecord' button as I used;  your way makes it possible to keep the relevant row in the grid grey-highlighted even when the focus is shifted to the edit field which is a more user-friendly touch.
Thanks,
Derek.

Re: What will happen if we do not use action new record

I'm interested in the undocumented property you have used EHW  - dbDon'tResetID, I can't find it anywhere or in the help or auto complete selection.

On a clear disk you can seek forever

Re: What will happen if we do not use action new record

When you have a save action and you do not close the form, a second click of the save button will save the record as a new record. In other words a second click of the save button will produce a duplicate record if you do not close the form. The dbDontResetID prevents this from happening. It does not set the increment on id and maintains the same id so a second click of the save button just saves the same record. It must be placed on the save button's onClick event. To be honest I learned about it from Dimitry in one of his posts a couple of years ago.