Hi Sparrow,
I understood this part, the problem is to know what is the name or the component reference of this combo!
There must be a reference to this combo somewhere, otherwise it could not exist or is there a trick to address an unnamed component in a form?

Yeah, actually I renamed the topic since we cannot interact with the frmdbCoreUsers.gridusers and actually it makes no sense to play with it since  the main issue is in the role combobox filtering in the frmdbCoreUserForm.

If the application has been compiled with a specific role and the role is deleted from the database afterward via sqlitestudio to hide it, the role will reappear in the database with a new id at next app launch. I do have buttons and fields reserved to developer in my app and I want to avoid anyone else to play with them. Without this restriction I must keep 2 versions of the app, 1 with the hidden dev features as well as no dev permissions and 1 without any of the dev features which is cumbersome.

It looks like the frmdbCoreUserForm combobox is a dynamic component and I don't get how to filter it.

Well... I cannot get anything working to manipulate at least the frmdbCoreUserForm.combobox to not display the role with id=3

I have tried all number in components[] without a result.

This is where I am at:

 frmdbCoreUserForm.components[21].dbFilter:= 'id IS NOT 3';

and the error is always Undeclared identifier:'dbFilter'.... whichever the number

Thanks guys.

@k425, I have downloaded the current available version of clearapp and I don't see the last line which you show on your screenshot.
I cannot read Russian but there is an absolute link instead of relative link to ".\Script\Tools\Dbg\resourses\clear.png" when clicking on the second item of first menu in the main form.

Thanks pavlenko.vladimir.v.

Does anyone know how the user grid and the role combobox in the frmdbCoreUsers are called?
I am trying to hide one user and one role from prying eyes.
https://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=10159

Yeah but the price of the product for commercial use is just prohibitive!!! I have thought of integrating some python script within MVD to do exactly the same thing but for free big_smile I am still working on it...

That looks very cool, if only we could design this kind of stuff within My visual Database!!

58

(5 replies, posted in General)

Except for the xml file, is there any other feature worth using the unofficial 6.61beta?

59

(6 replies, posted in General)

I know about the version, I was talking about the new "export to CSV" feature and wanted a way to ask the user where he wants to save the file via the scripts above instead of having a handwritten path in the script. I al still working on how to include Sparrow's answer to the function / procedure written by Drivesoft, that's because I am still a bit slow in the Pascal side smile

60

(6 replies, posted in General)

Is there a simple way to ask the user for the file path and name of his/her choice via an explorer window instead of having a fixed path for "FileName"?

Hi all,

I know it is possible to hide a column in a tablegrid but is it possible to hide a row or a specific record according an id in a tablegrid result?

So... I have been struggling quite a bit with the duplicate checking on records already existing when updating and I finally found something that works.

The above works well for a new record but it blocks any update on existing records considering an edit as a systemic duplicate.

My form has a double function of inserting new entries and displaying existing records so, the "show record" and "new record" do not behave as expected, especially the "show record" that requires to double-clic twice (4 clicks) to retrieve the current id/generated id.

If someone has the same kind of issue, here is the fruition of a long battle and some headaches.

The key is in the operator != which compares the values left and right and returns a false instead of the <> which returns a true and with SQL all conditions must be true to get a true result. If at least one condition is false then the result could be either false or incomplete, This is why it did not worked for updates since the result was always true, hence duplicate alert. In a new record, the ids old (-1) and new (next id number) are different while when updating, the ids are the same. SQLite creates internally an "old.id" and a "new.id" before each transaction, those can also be used in triggers and are used for internal rollback.

procedure Form_SaveButtonName_OnClick (Sender: string; var Cancel: boolean);
var id: integer;
begin

  if  (SQLExecute ('SELECT COUNT(id) FROM table WHERE (column COLLATE NOCASE ="'+Form.TextBox.Text+'") and (id!="'+inttostr(Form.SaveButtonName.dbGeneralTableId)+'")')) > 0 then
     begin  // Replace <Record> by proper descriptive field
          MessageDlg('This <Record> already exists:  ' +Form.TextBox.Text +#13+'Entry canceled', mtError, mbOk, 0); // Displays a red 'X', header is: Error
          Cancel := True;
          end
          else
          begin
           MessageDlg('This <Record> has been saved:  ' +Administration.Administr_WinID.Text, mtInformation, mbOk, 0); // Displays an Info icon header is: Information
          Cancel := False;
     end;

end;

Nice evolution of the filtering system!!

How about an evolution of the grid display without having to script everything like this:

 // Columns alignment
  Administration.UserlistGrid.BestFitColumns(bfBoth);
  Administration.CCGrid.BestFitColumns(bfBoth);
  Administration.RMList.BestFitColumns(bfBoth);
  Administration.IMGList.BestFitColumns(bfBoth);
  Administration.TypList.BestFitColumns(bfBoth);
  Administration.DptListGrid.BestFitColumns(bfBoth);
  //Columns distribution
  Administration.UserlistGrid.Columns[0].width := Administration.UserlistGrid.width div 6;
  Administration.UserlistGrid.Columns[1].width := Administration.UserlistGrid.width div 6;
  Administration.UserlistGrid.Columns[2].width := Administration.UserlistGrid.width div 6;
  Administration.UserlistGrid.Columns[3].width := Administration.UserlistGrid.width div 6;
  Administration.UserlistGrid.Columns[4].width := Administration.UserlistGrid.width div 6;
  Administration.UserlistGrid.Columns[5].width := Administration.UserlistGrid.width div 6;
  Administration.CCGrid.Columns[0].width := Administration.CCGrid.width div 4;
  Administration.CCGrid.Columns[1].width := Administration.CCGrid.width div 4;
  Administration.CCGrid.Columns[2].width := Administration.CCGrid.width div 4;
  Administration.CCGrid.Columns[3].width := Administration.CCGrid.width div 4;
  Administration.RMList.Columns[0].width := Administration.RMList.width;
  Administration.IMGList.Columns[0].width := Administration.IMGList.width div 2;
  Administration.IMGList.Columns[1].width := Administration.IMGList.width div 2;
  Administration.TypList.Columns[0].width := Administration.TypList.width div 2;
  Administration.TypList.Columns[1].width := Administration.TypList.width div 2;
  Administration.DptListGrid.Columns[0].width := Administration.DptListGrid.width;

Most of the time, when more than 1 table grid are used on the same form, the columns are shown like there is no more intelligence in the system, with a fixed 1 character wide by default if you are lucky.

That is what the collate nocase does! wink

65

(4 replies, posted in General)

It all depends on how you want to proceed, if using the user interface only, you can use a button with "show record" property which will open the record into a form. You can also use the in-place edit, a tablegrid property (editable) or use SQL Queries as shown by Brian.zaballa.

Got it, to check case insensitive duplicates, use COLLATE NOCASE:

function DupliChk (sTable, sField, sValue: string;): boolean;
var d: string;
begin

    d := SQLExecute ('SELECT Count(*) FROM '+sTable+' WHERE '+sField+' COLLATE NOCASE = "' + sValue + '"');
    if StrToInt(d) > 0 then result := True else result := False;
end;

It works until someone tries to cheat it with a space before or after the entry...

It worked the other way around, I tested it but you are right, it looks more logical your way.

Now, I have to find a way to check on the vicious duplicates, the one mixing lower case and uppercase like: HR ..... Hr ..... hr ....  hR ...., Human Resources..... human resources  .... HUMAN RESOURCES ....  those are all duplicates!!! sad

I transformed your solution into a function as it is easier when used repeatedly. It works perfectly when using a form that was not called by a "New Record" button.

function DupliChk (sTable, sField, sValue: string;): boolean;
var d: string;
begin
    result := False;
    d := SQLExecute ('SELECT Count(*) FROM '+sTable+' WHERE '+sField+' = "' + sValue + '"');
    if StrToInt(d) > 0 then result := True;
end;

And the usage is:

procedure Form_ButtonSave_OnClick (Sender: string; var Cancel: boolean);
begin

   if DupliChk('Table','Column',Form.EditBox.Text) then
     begin   //replace object by self-explanatory text
          MessageDlg('This object already exists:  ' +Form.EditBox.Text +#13+'Entry cancelled', mtError, mbOk, 0); // Displays a red 'X', header is: Error
          Cancel := True;
          Form.EditBox.Clear;  
     end;
end;

69

(13 replies, posted in General)

Which progress bar?

Thanks pavlenko.vladimir.v, that looks so simple, I feel dumb.

It actually does not work with the action 'SaveRecord'. I have attached an example of what I am trying to achieve.

I want a very simple way of checking duplicates in a handful of tables in the same way as the example.

72

(6 replies, posted in General)

There is a RTF memo component, the one with a little red A.

pavlenko.vladimir.v wrote:
tcoton wrote:

This method works only when using a "New Record" button, it does not work with a "Save Record" button.

I tried to add the Action='SaveRecord' but it might be another string sent when using a "Save Record" button:

..[snip]....if (Action = 'NewRecord') or (Action='SaveRecord') then....[snip]....

Does anyone knows what the string sent is?

?????

I am using Dmitry example up in the post.

This method works only when using a "New Record" button, it does not work with a "Save Record" button.

I tried to add the Action='SaveRecord' but it might be another string sent when using a "Save Record" button:

..[snip]....if (Action = 'NewRecord') or (Action='SaveRecord') then....[snip]....

Does anyone knows what the string sent is?

75

(1 replies, posted in General)

Hi all,

I have a curiosity question: When calling a form containing one or many grids with auto queries from a button "show form", the grids are automatically refreshed and display any data requested, why is it not the case when calling the very same form from a script that contains either ShowModal or Show, the form appears but the grids are empty unless we write the scripts with tablegrid.dbupdate?