Topic: Assign a field value to a grid record

Hello,
I am working on a demo where office staff are listed in a table and it is used to monitor who is in the office and who has left the building. It would be run in a multi user environment. When the table is visible, a person should single click a record and then be able to click a button to set the Status field to show Onsite or Away. Then all staff can see if a person is in the office. To make the change visible a Form1.TableGrid1.dbUpdate; may be needed after. I am struggling with the command and have attached the basic project. There are commented commands I was using as a guide so ignore those. I could be well off track with how to do this so help is appreciated.
Thanks in advance, David

Post's attachments

Attachment icon Staff monitor.zip 326.47 kb, 437 downloads since 2016-03-31 

Re: Assign a field value to a grid record

Hi David,
I wanted to have a look at your project but couldn't open it.  What version are you using?  I'm using MVD 2.5 beta (which I thought was the latest) but the error says you're using a more recent version.
Derek.

Re: Assign a field value to a grid record

Hello Derek, thanks. I have Beta 2.5 supplied from Dmitry on topic
http://myvisualdatabase.com/forum/viewtopic.php?id=2275
which was a response from Dmitry 18/03/16. The topic heading is "Trouble with unsetting the default property for a button".
Thanks again and look forward to hearing from you. David.

Re: Assign a field value to a grid record

Hi David,
Bit of a mystery - downloaded the latest version from your link and I still get the same error.
Anyway, from what you described, it was enough to see what you're trying to do.
Attached is the way I'd probably tackle it - and you can see where I've put the table refresh.
I appreciate that the forms and fields are not as you want them but I was working blind not being able to open your project.
Hope this helps,
Derek.

Post's attachments

Attachment icon SM.zip 338.16 kb, 466 downloads since 2016-04-01 

Re: Assign a field value to a grid record

Hello David and Derek

Very interesting this way to set IN or OUT directly into the grid from only a button, without using a second form.
I hold this idea as a snippet.
Thanks

JB

Re: Assign a field value to a grid record

Hello Derek,
You understood perfectly thank you. You also added the cell colour which I wanted too.
Thanks and regards, David.

Re: Assign a field value to a grid record

Hi David, Hi JB,
I was rushing a bit (no excuse!!) and forgot to add a line in the script to re-focus the cursor on the row that has just been 'clicked' to change from 'IN' to 'OUT' and vice versa. 
So, in the script and after the line
    form1.tablegrid1.dbupdate;
please add
    form1.tablegrid1.setfocus;
I know it's just cosmetic but it's a pet hate of mine to have to re-click back into the table all the time.
Thanks, and glad it helped.
Derek.

Re: Assign a field value to a grid record

Pure genius, thank you!