Rather than using the script facility to write a filter, I thought I might be able to parse an edit box into the filter query in the 'set up auto query'. Sadly this does not work, as it appears the filter searches for a column with the edit box name.


When a script is used either the SQLQuery or the SQLExecute are quite happy to have a component in the SQL text, so somewhere there is the ability to parse components into a SQL statement.


Before I give up and write the script, does anyone know if it is possible to retrieve the contents of an edit box and parse them into the filter script? 


Image attached of what I'm trying to do. This creates the error; 'No such column frmMain.edtAssGroup.text' .


I have tried

(( assemblyNo ="{edtAssGroup}") AND (subOrdinateParts.id_part_categories != 2))

  This doesn't cause an error message, but it doesn't work possibly because edtAssGroup is on the main form and not on the form I'm using to display this filtered result.


Thank you in advance.

202

(2 replies, posted in General)

Unforgettable,

This means the entry is linked in two or more tables in your database. In other words you have  a table which contains all your items and then you have another table that uses an entry in that table as a foreign key, often the 'id' number.

Assuming your tables aren't corrupt, check which entry you are actually trying to delete, the foreign key in a table or the actual data.  You need to delete from all tables that the entry exists in starting with the foreign keys and then the main entry.

Check if you ticked  the 'Cascade Delete' option if you are using the inbuilt delete option.


See the attached picture.

203

(1 replies, posted in Script)

I'm wondering if anyone else has had this problem.

I like to work with separate PAS files for large programs, so each form has its own script file. They are declared like so

uses
    'technicians.pas', 'suppliers.pas', 'editPart.pas', 'partMaintenance.pas', 'lookup.pas','editAssembly.pas';

Now I have a button click event that when I place it in the 'editAssembly.pas' file MVD does not recognise it, in fact it ignores it. It sees all the other code in the file but this one event.


The moment I cut the procedure from the file and paste it into the main script file MVD sees it and compiles it.


I'm suspecting there is some sort of corruption that occurs in the XML file, but it is strange that it only is happening with this one button click event.


I'm not in a position to zip the scripts up tonight, but I'll do so tomorrow. In the meantime anyone else had this conundrum?

MVD V6.3

204

(5 replies, posted in General)

john wrote:

Ok, i have paid for the product, where do i get a key?


You should receive an email with it in.

На форуме есть программа, которая использует SMS, выполняет поиск по слову SMS, и сообщение должно появиться. Это было совсем недавно.




There is a a program on the forum that uses SMS, perform a search with the word SMS and the post should appear.  It was quite recent.

Google Translate.

Мне очень интересны ваши курсы. Они только на русском или есть английские версии?

Ваш веб-сайт я использую Google переводчик, чтобы прочитать страницу.


I am very interested in your courses. Are they only in Russian or are there English versions?

Your website I am using google translate to read the page.

207

(11 replies, posted in General)

I think you might require a 3rd table as the intermediary .

Your Users is the parent link  table - you have a link in your Housing table back to Users .


As an example I am working my way through an 'orders' database.   I have Technicians who can have many orders and those orders have multiple items.


I've attached part of my schema - so for you Technicians = Users and Houses = Orders, I'm struggling to think what you would call the 3rd table.  You might not need a third table, but if you find you are entering the same house data for more than one User theoretically you ought to move the data to another table.


Now that I've confused you and me, the picture is attached below.   There is a website that has over 300 database schema to look at as a base idea. The moment I can find it, I'll post the link. The author designs database for the US and UK councils etc.

208

(6 replies, posted in General)

Hi eyeman303,


I'm sure Derek will be browsing through later,  but if you have downloaded Derek's example above, then all you have to do is build on it slightly.


There are two ways that spring to my mind, you can make a CASE statement (which is just a fancy and neater looking if...then...else) or an if..then...else.

procedure Form1_TableGrid1_OnChange (Sender: TObject);
var  vi, myValue: integer;
begin
  for vi := 0 to form1.tablegrid1.RowCount -1 do
    begin

     myValue := form1.tablegrid1.cell[4,vi].AsInteger;

      case myValue of

          11..20:    form1.tablegrid1.cell[4,vi].color := $0085E873;
       
           21..30:   form1.tablegrid1.cell[5,vi].color := $008080FF;

        end;
    end;
end;

Note I haven't tested the above.

209

(43 replies, posted in Russian)

Причиной двойных кавычек является то, как MVD представляет все операторы SQL внутри. Это правда, что вам не нужно представлять их при использовании сценария.


Однако предоставленные мною фрагменты кода - это действующие фрагменты кода из моего текущего проекта.


Inilka, было бы полезно, если бы вы могли опубликовать фактический текст ошибки или изображение полученного вами текста ошибки.
Я упустил тот факт, что вы пытаетесь использовать вычисляемое поле.



The reason for double quotes is this is how MVD represents all the SQL statements inside. It is true that you do not need to represent them this way when using the script.


However, the code snippets I provided are valid code snippets from my current project.


Inilka, it would be helpful if you could either post the actual error text or a picture of the error text that you are getting.
I missed the fact that you are trying to use a calculated field.


Using Google translate.

210

(43 replies, posted in Russian)

У вас нет правильных кавычек.


You don't have the quotation marks correct.

See (.......... "2"')


Change /+ Изменить

"name_status_etalon_ks".id = 1 ORDER BY "date_status" DESC LIMIT 1');

To /к

"name_status_etalon_ks"."id = 1" ORDER BY "date_status" DESC LIMIT "1"');

211

(43 replies, posted in Russian)

Maybe this will help:

 assemblyGroup := SQLExecute('SELECT assemblyNo, id_Part_categories FROM subOrdinateParts WHERE subOrdinateParts.id_products = "'+ intToStr(form1.Tablegrid1.dbItemID)+'"  AND "subOrdinateParts"."id_part_categories" = "2"');


With Joins:


 form1.TableGrid2.dbSQL:=('SELECT DISTINCT "products"."LineNumber" as "BSUITE#","productSupplier"."description" as "DESCRIPTION","productSupplier"."supplier_part_number" as "PART CODE","suppliers"."supplierName" as "SUPPLIER","part_categories"."notes" as "CATEGORIES" FROM "subOrdinateParts" LEFT OUTER JOIN "suppliers" ON "subOrdinateParts"."id_suppliers"="suppliers".id LEFT OUTER JOIN "part_categories" ON "subOrdinateParts"."id_part_categories"="part_categories".id LEFT OUTER JOIN "productSupplier" ON "subOrdinateParts"."id_productSupplier"="productSupplier".id LEFT OUTER JOIN "products" ON "subOrdinateParts"."id_products"="products".id WHERE "subOrdinateParts"."assemblyNo"= "'+assemblyGroup+'" AND "part_categories"."notes" != "Master Part"');

212

(0 replies, posted in General)

I'm hoping to avoid using an OpenDialog class as I'd like to be able to read in from my database the link to a file and just click on a button and the correct program will open according to the file extension.


I've experimented with the OpenFile function , but this requires the 'OpenWith' string to be hard coded. The only way around that I can see is to read in the file link, determine the file extension and then via some case statements 'plug in' the correct program string to open the document etc.


I haven't tried it yet as I've only just spotted it, but now I'm wondering if playing with ParamStr() would do the trick?

213

(2 replies, posted in General)

I've just had a further thought.  If you are using a tablegrid to view your records, you could use the ARow parameter from the cell_on_click event  as your counter and just add 1 to that.

214

(2 replies, posted in General)

unforgettable,


What you need is something along the lines below. I don't normally have a button, I tend to use an 'on_cell_click' event of a tablegrid, so you'll need to play around with the code below.


I'm sure there is an easier way, but it isn't springing to mind at the moment.


You need to set up a dataset and then use your next button to action the function dataset.next.

Here is some code:

procedure next(nextrow: integer);
var
  index,count : integer; //loop counter
 ds : TDataSet;   //dataset to read your database
begin
  
count := SQLExecute('SELECT count(*) FROM tablename); //get maximum rows in table

  SQLQuery('SELECT column(s)_you_want FROM table', ds); //read in your database and hold it in DS
 ds.first; // make sure you are at the beginning of the data

 for index := 0 to count-1 do
 begin
     //here you need an array a table grid or edit boxes whatever you are viewing the table in
  array[index] := ds.fFieldByName('a _field_in_your_database').asString;
 ds.next; // this is the bit you need to have in your button click
end;
ds.close;
end;

What you could do, is have the index increment in the button click event, and call your next procedure. In the procedure remove the for loop and pass in the index  parameter and then use 'nextRow'  instead if index above. In other words it would be array[nextRow] := .......  instead of array[index].


Sorry I'm a little unclear, I'm trying to get my project running some extra stuff for tomorrow and it is past 8pm here and I'm running out of time.

215

(2 replies, posted in General)

Does this post help at all?

http://myvisualdatabase.com/forum/viewt … 542#p35542

Ronin751,


Search for the code called DRAMA, it was posted here recently by someone whose name I can't locate (possibly DAZ) forgotten.  They have done exactly what you are looking for I believe.



Ищите код под названием DRAMA, он был недавно размещен здесь кем-то, чье имя я не могу найти (возможно, DAZ) забыли. Они сделали именно то, что вы ищете, я верю.

Translated by Google

217

(10 replies, posted in General)

Ignore my suggestion above, I've just tried ping('google.com);   in the middle of some code and I get no errors on compilation.


So it looks like a case of commenting out chunks of your 'if ping' statement until you find the culprit.

218

(10 replies, posted in General)

I've just looked at MVDs Ping function and perhaps you don't have enough parameters.

It shows  Ping(string,boolean,Timeout)   and returns a boolean.

Perhaps you should try :  Ping('google.com', false, Timeout);   False means you aren't raising an exception on error and Timeout has a default of 1ms.

219

(10 replies, posted in General)

Humblelion,


Is this definitely where the error occurs?


Have you tried commenting out parts of your code? I mean if you were to comment out If PING to the ELSE temporarily, do you still get the error?


Are you missing any semicolons before your call to this procedure?

220

(10 replies, posted in General)

I think this post (in Russian) may have another answer for you and will solve your problem.

http://myvisualdatabase.com/forum/viewt … 076#p37076

221

(4 replies, posted in General)

Thank you for your code Derek, I particularly like the 'sub-pop-up-grid' idea, something I hadn't thought of at all.

222

(3 replies, posted in Script)

Argonex,


I assume you are displaying the results in a table grid.  If I understand your question correclty, all you need to do is set the 'sort' option in the table grid settings, see my attached picture.

You might have to also write into the filter option GROUP BY OrderNo so you only see each item once.


I think to fully get where you want to be you are going to have to write your own SQL script, I'll have a think on that.

223

(10 replies, posted in General)

MarkOs,


It looks like I misunderstood your original post. You will need to either use the Windows Public folder to store your images  or make a folder off of your program exe folder.


I'm assuming the other PC does not have the file path C:\Users\Marko\   your alternatives are:

Have a path such as C:\some_folder\filedelete2a\gallery\ or write code to convert your links to equivalents on another PC.


The 'User' folder in Windows tends to be set to 'read only' so is not always a good place to store files.


Depending on your program and how you wish to deploy it it may or may not be worth the extra work in writing code to find the current_user_path and then convert your link by substituting your C:\Users\MarkOS to C:\Users\some_other_person.


Personally I would make a folder in a neutral part of the drive (that is any path but one that contains your user name) and the link will always be the same on any PC.


You would need to put into your script something like the following:

CONST
DIR = 'c:\filedelete2a\gallery\'

procedure gallery;
begin

ForceDirectories(DIR);

end;

That would need to be called in your forms'  'ON SHOW ' event or you could just place the code  ForceDirectories(DIR) straight into it and not call a procedure.

224

(4 replies, posted in General)

Just in case it is impossible to do what I'm hoping with the  TreeView component, I've temporarily added a table grid to the form.


[SOLVED] see bottom of post
For a reason I can't fathom, I'm unable to set row[0] to a text colour without clicking on the row. Making it bold on viewing works, it is just the text colour that doesn't show on view without clicking on it. I haven't tried placing a hidden button on the form and attach that to the font colour and then add a button click to the code below.


I'm now thinking I might make a tablegrid into a pseudo tree if my first post is impossible - that is row[0] displays as normal and then I make all subsequent rows move over by one column to the right or right align column[0].


The code that isn't automatically changing the font colour is below.

procedure Form1_TableGrid2_OnChange (Sender: TObject);
var
 iRow,iCol, NumCol : integer;
begin
  NumCol := form1.TableGrid2.Columns.Count -1;
  subOrdinateGrid;  //this formats the header and alignment
 // form1.TableGrid2.SetFocus;

  for iCol := 0 to NumCol do
  begin
    form1.TableGrid2.Cell[iCol,0].TextColor := clRed;
    form1.TableGrid2.Cell[iCol,0].FontStyle := fsBold
   
  end;
end;

*** The reason I couldn't get row[0] to show  a text colour without clicking was because elsewhere I had set the   TableGrid2.SelectRange to True for row[0].  Comment this code out and all works as expected.

225

(4 replies, posted in General)

I have a couple of questions about using the treeview component that don't seem to be covered by either Dmitry's examples or those by K245 on his website or the recent example of DRAMA2 posted by  .


1. Is it possible to use a variable to operate the filter rather than hardcoding it in the treeview settings page? I don't see a filter option published as a property in the component help.


2. Is there an easy way of working out the index position of the branches?


This maybe a moot problem if I can use a variable to alter the filter search. The problem occurs if I need to add items to the tree other than manually counting the number of items per node, Is there a way to customise the text on the menu popup when right clicking on the tree when the editing functions have been enabled?


3. If in the end I have to manually make the treeview in script, how do I  make headers/titles as the actual component allows under Settings? Options does not seem to be a published property


What I need to do is to select an item from a standard grid (the Master part) and then have this part 'open up' in a treeview which shows an assembly of parts under it.   


The attached images shows the result I want to get, I have manipulated the database manually to achieve what is in the image of the treeview.  The lower treeview is one I created manually.