Topic: Special Read Only field

Hi,


is it possible (or simple) to create a specific field where you can input data only once and then this field is set to read only.

example for a corporate PBX phonebook database:

I have 2 fields which should be linked together and are unique in my Add & Edit form : Position and TK

These fields should only be filled once and never changed afterward in the Add or Edit but other fields can be edited.

See attached screenshot.

Post's attachments

Attachment icon mvdb-fields.jpg 60.53 kb, 319 downloads since 2014-12-09 

Re: Special Read Only field

Hello,


Yes, you should create event OnClick for button with action "Save Record"

procedure Form2_bSave_OnClick (Sender: string; var Cancel: boolean);
begin
    if Form2.dbAction = 'ShowRecord' then
    begin
        ShowMessage('You cannot change this record.');
        Cancel := True;
    end;
end; 

If form opened for editing record, you can cancel action of button: "Save Record"

Dmitry.

Re: Special Read Only field

The problem is more complex.

If the field is blank, then it should be filled in but once it has been filled, it should switch to read only but the other fields should remain editable.

It is like write once and read many for one or two fields only.

Re: Special Read Only field

Please, create event OnShow for editing form:

procedure Form2_OnShow (Sender: string; Action: string);
begin
  if Form2.Edit1.Text <> '' then Form2.Edit1.ReadOnly := True else Form2.Edit1.ReadOnly := False;
end; 
Dmitry.

Re: Special Read Only field

Looks nice but if I copy / paste your code in a script tab, I get an error : "BEGIN expected at 5:1"

I do not understand how to do it (feel like a noob)....

Re: Special Read Only field

Before, you must create event OnShow, how to do it, please read here:
http://myvisualdatabase.com/help_en/scr … rview.html



Also you can send me your project, I will help you.
support@drive-software.com

Dmitry.

Re: Special Read Only field

I would like to learn by myself so my life would be easier afterward but still I do not understand how to implement action scripts.

It might be super easy for you but even with the new help in English, I really do not understand. Displaying a message is an easy task but here, there is an action to implement and I do not know how to manage this action.

I paste your code and changed the values to match my project but I still get an error. The explaination in the help is not clear for end-users with no developer background. The application is supposed to ease the way we create database application, but we need some basis for this kind of feature.

I do have some skills in SQL and lots of other subjects but none in Pascal, unfortunately. What should be after the next "begin"?

Re: Special Read Only field

Please, send me your project, I'll find error and  try to explain the error.

Dmitry.

Re: Special Read Only field

I will send you my project but without the script as I do not understand how to implement.