2,401

(12 replies, posted in General)

Morning Gieri, Thierry,

I was having a look at your project and there are a couple of things that you could try and change (all on Form1) to see if it does what you want.
1)
I think your 'search' (button4) doesn't behave correctly because you have included tablegrid1 as a selected component.
2)
You also do not need an incremental search on tablegrid1 pointing to button4.
3)
I would add an incremental search on edit2 and edit 3 pointing to button4 instead.
4)
You could change the filter properties for edit2 and edit to %s% to perform incremental wild-card searching
5)
If you do 4) and 5) you can hide the 'search' (button4) totally as it is now working incrementally
6)
You can add counters to tablegrid by using the tablegrid settings (where you add the column, column headings etc - click  'footer' and select 'count' option
7)
If you want to select multiple rows for deletion, you can also use 'go multiselect'  which is a property of the tablegrid (properties / options) instead of adding it in a script
8)
when selecting multiple rows in a tablegrid, you select the first row as normal AND THEN hold the CTRL key and select  any others;  if multiple rows display in the tablegrid as highlighted, you have done it correctly.

I hope this answers some of your questions helps.  I have included all of the points in the attachment.

Derek.

2,402

(5 replies, posted in General)

Hello Gieri,
When I made the example, I was in a rush and only showed you the quickest and easiest way to do it.
Now that I have a bit more time, I have added another couple of different ways you could do it - they are all in the attached .zip file. 
All 3 different approaches will work as 'basic' MVD (ie no coding).
However, if you want to have color-coding on the rows in the grid, you will need to use a script.
Hope this will give you more ideas.
Derek.

2,403

(5 replies, posted in General)

Hello Gieri,
Both approaches are possible;  it just depends how you want to display the information.
A quick and very easy way to do it without having to write any script and without having to set up an archive table, is to use 2 grids, each grid being filtered according to whether the 'todo' has been finished or not.
I have attached a small example for you.
Hope this gives you some ideas.
Derek

2,404

(3 replies, posted in SQL queries)

Hello Alsu,
One way is to do it with a small script.
I have added it to your project and attached it;  you might want to do it differently but at least it will show you how to write it.
Hope this helps,
Derek.

2,405

(6 replies, posted in General)

Hello Lee,
My understanding (may be wrong) is that the scripting language only supports a sub-set of functions and that the syntax for those functions is often specific to MVD, which is why finding 'answers' on Google or in SQLITE studio etc confuses rather than helps. 
For that reason, for me the best way of finding out how to do something in MVD is simply by using the SEARCH function within the forum itself - it can be a bit tedious reading all the relevant (and not so relevant) posts but at the same time, it's surprising what else you come across that you might use later on, so it's never wholly wasted.
Derek.

2,406

(6 replies, posted in General)

No problem Lee - just glad to be able to give something back after all the help that I'v'e received from various members (yes, you know who you are - LOL!!).
Bit worrying though that you understand my SQL - not sure I do myself half the time!
Derek.

2,407

(6 replies, posted in General)

Hello Again Lee,
I forgot to mention in my response that I think you'll also need to amend the relationship you've created in line 4 of your script. because when you add more seasons to the data, your script, as it stands, won't know which season to use to add the wksplayed to. 
I'd suggest something like this:
form1.edit22.Value:= sqlexecute('select IFNULL(max(wksplayed), 0) from matches where (id_seasons = ' + form1.combobox5.sqlvalue + ') and id_teams = ' + Form1.ComboBox1.sqlValue) + 1;
Hope that makes sense.
Derek.

2,408

(6 replies, posted in General)

Hello Lee,
Sorry not to have been able to help out recently - I've been away.
Looks like your project is really starting to take shape.
With this specific problem you're asking about, I think you need to amend line 4 of your script to read;
form1.edit22.Value := sqlexecute('select IFNULL(max(wksplayed), 0) from matches where id_teams = ' + Form1.ComboBox1.sqlValue) + 1;

As it stands, when no record exists, the wksplayed value is set to 1 and the first record is created.
When 1 record exists, it uses the wksplayed value of the first record (ie 1), adds 1 and creates a second record with a wksplayed value of 2.
When 2 records exist, it still uses the wksplayed value of the first record (ie 1), adds 1 and creates a third record BUT with a wksplayed value of 2.
When 3 records exist, it still uses the wksplayed value of the first record (ie 1), adds 1 and creates a fourth record BUT with a wksplayed value of 2.
And so on and so on - it will NEVER go above a wksplayed value of 2

This is where the 'max' instruction in the script comes into play;  using 'max' in the script forces it to read the last record and then add 1.  This should then start incrementing the week numbers correctly.
I trust that makes sense and hope it helps,
Derek.

2,409

(2 replies, posted in Script)

Hello Jean,
Perhaps I am misunderstanding but does something like the attached do what you want but without a script to perform the search? 
(I use the script only so the user can quickly focus on the first row in the tablegrid with a 'tab' key).
Maybe this helps?
Derek.

2,410

(16 replies, posted in General)

Hello Lee,
Had a quick look and came up against the same problem.  You can either have
1.  the parent comboboxes working as you want but the grid doesn't display the away team properly (and then the data gets messed up if you do 'edits').
2.  the grid displays correctly and the integrity of the data is maintained when editing BUT the parent comboboxes don't work.
I believe it's because MVD is treating the 'home' parent combobox and the 'visitor' parent combobox as the same field of data when it comes to saving the record.  I'm certainly not saying it's a bug - it's more to do with how you want the form to work.  If the 'home' team and the 'away' team were added/edited on separate forms, I think it would be okay but I appreciate that's not how you'd want it working in the 'real world'.
The only compromise I could think of, which may be acceptable, is as follows;
1.  forget about using parent comboboxes
2.  in the home and visiting player comboboxes, display not just the player name but the team name and the player name together (so there is a visual check that the correct player is being chosen). 
To simplify this, I'd sort the home and visiting player comboboxes by team so that they are all grouped together.  Have a look at the attached screenshot if you're not sure how to do that (sorting the combobox by team is a small hack).
One other thing I noticed was you'd scripted for the 'search' button to be automatically 'clicked' when an item in the combobox is selected;  I'm not sure if you're aware but there is the 'incremental search' option (one of the object properties) that already does this for you (it's more obvious on an 'edit field' rather than a 'combobox' - see the second screenshot). 
Hope some of this helps to move things on a bit.  You could certainly have picked an easier project as your first one, but I guess any projects you do after this will seem a breeze in comparison - LOL!
Derek.

2,411

(5 replies, posted in General)

Hi Lee,
A couple of things to mention.
CALCULATED fields are just containers to temporarily hold the result of calculations based on actual data fields (it avoids data redundancy).  Look at the attached screenshot  - 'calcarea' is defined in the table 'lee' in MVD, but doesn't exist in SQLiteStudio (the raw data).  And because it doesn't actually exist, it will always get re-calculated when you next run your program.
Default values, on the other hand, are what you want the initial value of an actual data field to be and will either get saved as that default value or saved with an amended value (either by input or by calculation).  But in either case, the data IS actually saved. 
Therefore, if a field is saved with it's default value, what you see next time round is the SAVED value and NOT the re-set default value (even though they may happen to be one and the same).
Knowing your project a bit, I think I can see what lies behind your questions and I hope this has clarified rather than confused matters - LOL!
Derek.

2,412

(16 replies, posted in General)

Hello Lee,
There were 2 main things I noticed when I looked at your latest version.
1.  Comboboxes 6,7,8,9 and 10 ( the  visiting team and the visiting team players) hadn't been added to the 'save' button on the 'scorecard' form.
2.  The visiting team and visiting team players were selected for display on scorecard.tablegrid1 but not on the grid associated with scorecard.button4 (the 'search' button).  When you are using a 'search' button, the search grid always takes precedence.
The most foolproof way to check if everything is being saved, is to double-click on the sqlite.db file and look at the raw data using something like SQLiteStudio.
I've attached your project back so you can see the changes and check if it's doing what you want now.
Regards,
Derek

Hello Gilberto,
I'm not sure if you want to call another form after inserting or editing a record or ONLY after editing.
I'd do it this way - first set a flag to show if the action is for a 'new record' or for an 'edit record', then create a 'show form' button and then use a script to create an 'onafterclick' event on the 'save' button on your form to click the 'show form' button.  Optionally, set the 'new record or change record' flag and the 'show form' button to invisible to tidy things up.
If you want to call another form after inserting a record as well (and not just on 'edit') you just need to delete the "if Action......." line from the script
I've attached a simple project to show how.
Derek.

2,414

(8 replies, posted in General)

Hi Lee,
I've attached your project with a couple of changes that I hope will give you what you're after.
I think there were 2 basic issues with what you were trying to do.
1.  You were trying to use the seasonname as the ID whereas the ID is always an internally generated number (have a look at the sqlite.db screen shot that's included in the attached .zip file), so it was never going to find a match.
2.  There was no reference on your matches form to which season you were wanting to use, so I have added a combobox so you can either select the season manually from the drop-down or, if you have previously highlighted a row in form1.tablegrid1, then the script will pass that record ID through to the matches form automatically.
Trust that makes sense.
Derek.

2,415

(6 replies, posted in General)

Morning JB,
I think I'd do it the same way as EHWagner is suggesting.  Not sure why you're getting any errors.  I probably wouldn't even use a variable (lazy!) - just put it straight into the label.caption and then reformat it directly.
The code I'd use would be:
procedure Form1_TableGrid1_OnClick (Sender: string);
begin
  form1.label1.caption := sqlexecute('select birthday from dates where id =' +inttostr(form1.tablegrid1.dbitemid));
  form1.label1.caption := copy(form1.label1.caption,9,2) +'/'+ copy(form1.label1.caption,6,2) +'/'+ copy(form1.label1.caption,1,4);
end;
Regards,
Derek.

2,416

(8 replies, posted in General)

Good Evening Lee, EHWagner,
Using a calculated field might be another way to go.
I've attached a quick example to show both options - and, as always, I'm sure there are other ways too ( I stick with what I can get to work, not what is necessarily the best!!)
Hope one approach or the other (or both) helps,
Derek.

2,417

(6 replies, posted in General)

Hello,
I think I would do it this way to save making an extra call to the database, but I am sure there will be other ways to do it too.
******************************************************************************
Var YY,MM,DD : integer; mydate: tdatetime;
procedure whatever_you_want
begin
    mydate := form1.DateTimePicker1.datetime;
    DeCodeDate (mydate,YY,MM,DD);
    form1.edit1.text := inttostr(dd) +'/'+ inttostr(mm) +'/' + inttostr(yy);
end;
******************************************************************************
I have attached this in a little project to show it working. 
Maybe it will help,
Derek.

2,418

(16 replies, posted in General)

Hello Lee,
The problem is with the structure of your teamplayers table;  you are trying to hold all 10 players on only one row;  this means that when you use the comboboxes, you will only ever see that 1 row of data.  Comboboxes are used to choose a row from a related table, not to choose a specific field from within a row.
The best way around it is to restructure your teamplayers table with (in your example) just 2 fields - the ID of the link to the teams table and the ID of the link to the players table.   You would then create 10 rows of data (one per player) for each team.
Then, on your scorecard form, you can use the combobox dropdowns with parent comboboxes pretty much as you were trying to do to select your 4 players from the 10 assigned to each team.
I've attached your project with the suggested changes - but as always, there are other options and maybe someone else might see a different way to do it. 
BTW, I've left the grid on the scorecard form simply because it's easier to check that the 4 players you've picked have been saved to the table correctly.
Derek.

2,419

(2 replies, posted in General)

Hi John,
I'd probably do it something like this (see attachment) but I'm sure there are other ways too.
The extra bit in the script is just so you can double-click in the grid rather than having to mouse down to the edit field (call me lazy!!).
Hope this helps,
Derek.

2,420

(16 replies, posted in General)

Hello Lee,
On Point 3), it sounds like you need to set up your teams and players and assign your 10 players to each team (as you are already doing).
Then on the scoresheet, select your team from the 'team' combobox and then make the 'team' combobox a parent of the 4 'player' comboboxes using the 'parent' combobox object property.  Hope that makes sense.
I've knocked up a small project to give you an idea how you might tackle it (sorry about the rubbish test data!).
Hope it helps,
Derek.

2,421

(16 replies, posted in General)

Hello Lee,
1.  In the combobox object properties for FIELDNAME, you enclose each of the fieldnames you want to display in curly brackets - {} and then insert as many spaces (or literals) as you want.  For example
{name},   {zip} / ({phone})   will give you - Lee,  01234 / (012345678)
2.  Displaying multiple fields in the combobox doesn't mean that this is how they are stored in the database - it is simply how you've asked for them to display on the form.  So, If I understand your question, you would need to reference whichever field you're interested in with an SQLEXECUTE statement in your script.  For example
sqlexecute('select name from customers where id ='+ inttostr(form1.combobox1.dbitemid)); or
sqlexecute('select zip from customers where id ='+ inttostr(form1.combobox1.dbitemid));
3.  Not quite sure what you're trying to do here - can you give us a bit more info - or some screenshots?
Derek.

Hello Dmitry,
Could NameCase be added as a new option to the CHARCASE object property for text fields (in addition to ecLowerCase, ecNormal and ecUpperCase) instead of having to do it by script?
Thanks,
Derek.

Hello EHWagner,
Something like this might do the trick for you -
procedure Form1_Edit1_OnExit (Sender: string);
begin
   form1.edit1.text := namecase(form1.edit1.text);
end;
Derek.

2,424

(13 replies, posted in Script)

Hi Lee,
Glad the suggestions have helped to move things along a bit.
Any more issues, then just post them and most people are happy to help if they can;  we're all just learning as we go along, same as you.
Derek.

2,425

(4 replies, posted in General)

Hi Again,
Didn't realise you were doing it all on the same form.
In that case, I might make my edit fields readonly and make them editable when clicking ADD or EDIT.
Instead of making them readonly, you could make them invisible - it's just another way of doing it although it can make the form look a bit odd.
Anyway, I have attached your project with a couple of suggestions, but, as I say, there are lots of different ways.
Derek.