Topic: Edit User Data

This might be a dumb question, but every sample app I look at uses a Grid to show the records and then you either double click or select Edit to modify the data.

How does one edit a record when there is only one record, or only one record that the user sees, for example, how does the user edit his first name and last name on his _user record when using roles?

I have a form called frmUser that has the fields but I don't understand how to load the data into it??? Is the best way onShow to grab the data for the user and put it in the text boxes, etc??? or is there a better way?

Thanks
Alan

2 (edited by derek 2020-12-04 22:22:07)

Re: Edit User Data

Hi,
For me, the easiest way is to continue using a grid - even if there is only record, it doesn't matter.
However, if you want to make it more user friendly, just make the grid and the edit button invisible.
So you'd use a script to
1.  highlight the only record in the grid
2.  click the 'edit' button
Please see the attached.
There are other ways (using an editable grid is a 'no script' option) but I think this stays closest to basic MVD functionality.
Derek.

Post's attachments

Attachment icon single record edit.zip 336.06 kb, 221 downloads since 2020-12-04 

Re: Edit User Data

Derek,

Thanks,

How can I add a filter so that when there are many rows in the table like _user to only filter for the current logged in user?

Alan

Re: Edit User Data

Would it be best to use the sqlexecute technique to load the grid with the one row i want?

5 (edited by derek 2020-12-05 14:49:16)

Re: Edit User Data

Hi Alan,
I would take the userid of the person who has logged on, copy that to form1.edit1 which is then used as the value to filter the tablegrid down to a single record.  The script then clicks the 'edit' button and displays the first and last names of the relevant user.
I've added an optional line to the script which hides the menu bar if the user does not have administrator privileges but you might already be doing that another way.
In the attachment, all passwords are the same as the userid's.
Derek.

Post's attachments

Attachment icon as single record edit fields.zip 337.59 kb, 198 downloads since 2020-12-05 

Re: Edit User Data

Derek, Alan,

Or you could use one line of code to retrieve the record without going through a tablegrid. See attached.

Post's attachments

Attachment icon as single record no tablegrid.zip 337.41 kb, 217 downloads since 2020-12-05 

Re: Edit User Data

ehwagner wrote:

Derek, Alan,

Or you could use one line of code to retrieve the record without going through a tablegrid. See attached.

I'm about to do something like this. Anyway. if you already have that frmUser form. You can open it and change Form1

frmUser.ShowRecord('_user', Application.User.id); // current logged on user
brian

Re: Edit User Data

Brian,
Worked perfectly.

Thanks


and the other suggestions too are now in my toolbox..

Alan