2,476

(10 replies, posted in SQL queries)

Hello Dmitry,
I have tried both your solutions and they work well.
I prefer your idea of putting the SQLQuery code into the script so that all of the grid formatting is properly maintained - looks much better.
As always, thank you for your help.
Have a good day,
Derek.

2,477

(10 replies, posted in SQL queries)

Good Afternoon Dmitry,
A bit of help please.
I have 2 currency fields, both defined to 2 decimal places and with a ',' as a thousands separator.
In my tablegrid when all rows are retrieved, this is displayed correctly, for example 1,234.00 (dmitry 1.jpg).
After doing an SQLQuery search, the formatting is lost and displays as 1234 (dmitry 2.jpg).
Can the correct format be specified as part of the SQLQuery?
If not, what is the syntax for specifying it in the script?
Thanks,
Derek.

2,478

(4 replies, posted in General)

Hi,
I am not sure if you have a need to store the cars you 'buy' and the cars you 'sell' in 2 separate tables with all the extra problems that might cause.
You could use just 1 table with extra fields to hold additional information about the 'sold price', 'sold date' etc.
Then all you need is 2 grids with filters - one grid automatically shows cars that haven't been sold (for example, with a 'sold price = 0.00) and the other grid automatically shows cars that have been sold (sold price > 0.00).
I have attached a little example of how I might do it if it helps.
Derek.

2,479

(13 replies, posted in General)

Hi TCOTON,
Can't believe it - a typo! Great spot!   A new pair of glasses for me, I think.....
Thanks for the link to cell justification.  I'm reasonably okay with grid formatting - my original question was more to do with the inconsistency - why you don't need to explicitly format it when you're simply viewing the grid but you then need to format it as a result of using an SQLQUERY.
Thanks again,
Derek.

2,480

(13 replies, posted in General)

Hi TCOTON,
I thought that when I first had the problem so tried it with just 2 conditions but it still didn't work.
And then I left outer joined instead - and still it didn't like it!  There is something wrong somewhere but I can't find it!
The only way I have got it to work is by using separate search fields for each column in the grid rather than using an SQLQUERY;  if I can't fix it, I may end up doing that on all the other columns as well, but it isn't quite the way I wanted it to be done.
Thanks again for your interest.
Derek.

2,481

(13 replies, posted in General)

Hi Tcoton,
Thanks for checking it out - I appreciate that.
I've tried changing the condition in the SQLQUERY a number of ways but it always comes back the same. 
I hope Dmitry can find out what the problem is.
Derek.

2,482

(13 replies, posted in General)

Hi Dmitry,

Thanks for your help.  What I have also done is copy your extra code from the tablegrid_oncellclick procedure and added it to the tablegrid_onkeyup procedure and now the filtered list stays in place to allow me to work through it.  It's 100% working!

I have 2 other questions please. 
1.  My SQLQuery searches for values in ALL fields and works okay except with the MODEL.model field.  For example, if I enter 'Volkswagen' into my SQLQuery, 4 rows are found (PIC1.jpg) but if I enter 'Golf', nothing is found (PIC2.jpg).  Can you see if there is anything wrong with my query?

2.  I have 2 currency fields that are displayed in the basic grid correctly (right hand justified).  But when I use the SQLQuery, the result shows in the grid as left hand justified (PIC3.jpg).  Is this a bug or do I need to explicitly format currency fields in the SQLQuery itself?

Thanks again for you help,

Derek,

2,483

(13 replies, posted in General)

Hello Dmitry,

I have an application where I am trying to perform my data maintenance (add, change and delete) all on one screen.  This makes it very quick to use which is an important requirement.
I have one main problem however. 
1.  All data rows are initially displayed corectly (picture1.jpg)
2.  A SQLSEARCH filter is applied to select a sub-set of data rows (picture2.jpg).  This also works correctly.
3.  I need to then makes changes to that sub-set of data rows.  But as soon as I click in the grid, the original full list is re-selected.
Is there a way to keep the sub-set of data rows until I have finished my changes and then re-select the full list? 
The way I was trying to write it was if there is a value in the SQLSEARCH field, then the grid displays the sub-set of data and if the value in the SQLSEARCH field is cleared, then the grid displays the full set of data.  But I have had no success.

Thanks,
Derek.

2,484

(8 replies, posted in General)

Hi Imcisco, Hi Jean, Hi Dmitry,

I see that Jean has already mentioned enabling 'auto execution of the query' on your list forms.

With regard to the other problem,  as your project stands at the moment, when you select a row in the FormSearch grid, it passes through the Design Name and SKU fields to FormInventory.  However, you need to add a button to act as a SEARCH, using the Design Name and/or SKU as the search parameters.

This isn't particularly 'slick' because you still need to 'click' the Search Button to see the effect.  So as an extra step, you can write a script to simulate the 'click'.  And if you've done that, you could also make the Search Button invisible so the User isn't even aware that this is happening.

I've done this in the attached zip file so you can run it and see if it's addresses your problem.  So.....
1) manually click the Search button on FormInventory to see the effect
2) go to the script tab and remove the // against the line  //forminventory.button1.click;   it now runs automatically
3) on FormInventory, change the Search Button property to 'visible' = false and run it again.

Hope this helps.

Derek.

2,485

(9 replies, posted in Script)

Hi Tcoton,
Maybe it's a version issue - I'm 2.0 Alpha on Windows XP(!) and it's fine with edit fields, comboboxes and datetimepickers.
Sorry about that.
Derek.

2,486

(9 replies, posted in Script)

Hi Tcoton,

With mandatory fields, as well as using .setfocus to take the User back to a field they've missed, I like to set it to a different color (as a non too subtle reminder!).  So, in Dmitry's code, you'd also have

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    if (Form1.ComboBox1.dbItemID = 4) and (not Form1.DateTimePicker1.Checked) then
    begin
        ShowMessage('Date is mandatory field.');
        Form1.DateTimePicker1.Color := clred;
        Form1.DateTimePicker1.SetFocus;
        Cancel := True;
    end;
end;

Maybe that helps.

Derek.

2,487

(3 replies, posted in Script)

Hi tcoton,
I only answer the easy ones - LOL!  I leave the complicated stuff to Dmitry!
Derek.

2,488

(3 replies, posted in Script)

Hi TCOTON,

I do much the same thing when the value in an edit field changes - I imagine it's exactly the same for a checkbox.

procedure form1_Edit1_OnExit (Sender: string);
begin
  if   form1.edit1.text   =     'ABC123'  then form1.color := $0066CCFF;
  if   form1.edit1.Text <>   'ABC123'  then form1.color := $00DCD9AF;
end;

Hope it helps and good luck,

Derek.

2,489

(10 replies, posted in General)

Morning Eddie, Morning Dmitry,

Just a couple of more ideas for you, Eddie.
I've taken my original knock-up application and in the tablegrid used '*' instead of numbers.  And in the form itself, I've made the 'star' rating system look a bit more 'interactive' by changing the star colour as each of them is clicked.
There are so many ways to approach it - all of which just goes to show how flexible My Visual Database can be.
Hope this has given you enough to go on.

Derek.

2,490

(10 replies, posted in General)

Hi Dmitry, Hi Eddie,

At first, I had defined the 'ratings' field as text and displayed in the grid '*' instead of '1', '** instead of '2' and '***' instead of  '3'.  This worked quite well and the script was very simple. 

But I then redefined the 'ratings' field as integer and displayed '1', '2' and '3' in the grid because I wanted to use tablegrid footers to calculate averages.

But visually, the way you have done it looks much more professional.   I have not seen Form1.TableGrid1.Columns.InsertGraphicColumn(n) used in the tablegrid lke this before - it will be very useful for new projects.

Thanks again,
Derek.

2,491

(10 replies, posted in General)

Hi Heribertom6466,
Attached is a cut down version of the script I used to get my 'star ratings' to work.  It's not the most sophisticated by any means (but it works!!).  If it helps, feel free to copy (and improve!).

Derek.

2,492

(10 replies, posted in General)

Hi Heribertom6466.
I had a similar requirement a while back.
My solution, although not as slick as I'd have liked (but it was quick and it worked) was to import an image of 5 Star ratings onto my form and then align 5 check boxes against the image.
When one of the check boxes was ticked, I then 'greyed out' the other 4 by script to stop people from using more than just 1 rating.
Depending on how you want to structure your table, you could have 5 fields (one for each star rating) or, as I did, have just 1 field and populate it with a value (1-5) depending on which of the 5 check boxes has been ticked (obviously, when re-displaying the form, you then need to take the field value and work out which one of the 5 check boxes gets the tick!).
Hope this helps and maybe gives you some ideas,
Derek.

2,493

(2 replies, posted in General)

Hi Dmity,
I just wasn't sure if there was a very easy way around the problem.   I'll add your code to my script and see how it works - but generally, I'd rather avoid writing to the registry for a non-critical problem - and having to manually move the forms is certainly not a 'show-stopper'.
Thanks for the quick response, as always.
Derek.

2,494

(2 replies, posted in General)

Hello Dmitry,
Hope you are well.  This is my scenario.
I have a simple application where the main form (Form1) is less than full-screen.
When I first run the application, Form 1 is centred on the screen (see dmitry languages 1.jpg). 
I move Form 1 - for example to bottom right of screen. 
I then open Form 2, but this is centred on the ORIGINAL location of Form 1 (see dmitry languages 2.jpg) and not the NEW location of Form 1. 
What I am trying to do is have Form 2 (and all the other forms) centred on the NEW location of Form 1 (see dmitry languages 3.jpg).
Can you suggest a way to achieve this (in effect, centring forms relative to their calling form)?
Thanks, as always, for your help.
Derek.

Hi Prahousefamily,
Picking up on Tcoton's answer, you could try something like this to output it as a label;

procedure Form1_DateTimePicker2_OnChange (Sender: string);
begin
  form1.Label4.caption:= inttostr(daysbetween(form1.datetimepicker1.date,form1.datetimepicker2.date));
end;

It only shows the elapsed period in 'days', not as 'years, months and days', but the principle is the same.

I knocked up a quick project to show it working if you need to have a look.

Good Luck,
Derek.

2,496

(5 replies, posted in SQL queries)

Hi Jean,
Glad it helped.
Now you can go on holiday and not be thinking about it!
Derek.

2,497

(5 replies, posted in SQL queries)

Hi Jean, Tcoton, Dmitry, Everyone!

I am not sure if i understand your problem 100% (i don't even understand my OWN problems 100%!!) but it may be that you need to specify the joins to the other tables as 'left outer' in your SQL query.

I have attached a copy of a project i did which has an example of this - please see the SQL query for Button 4 on Form1.  And if you need it, the administrator password in the project is uppercase 'MVD' !

Hopefully, this might help you a bit.

Derek.

2,498

(15 replies, posted in General)

Hi Again TCOTON,
Just a thought - to give the effect of a User clicks 'add' ----> pop-up with a droplist,  could you instead click 'add' ----> call a form which contains menu buttons which, when clicked,  then show different forms depending on what you need to do? (please see attached).
Derek

2,499

(15 replies, posted in General)

Good Evening Tcoton,
When i saw the screenshot in your earlier post, i thought the structure looked like something i was working on a while ago (but with not so many tables!).
So i copied, cut and pasted the basics of that project, changed a few labels etc and have attached it.
I was in a hurry so it isn't very well laid out and the data is just rubbish - sorry for that!
Maybe you will find it helps a little bit.
Derek.

2,500

(3 replies, posted in General)

Hello Dmitry, Jean,
Just downloaded 1.52 and added the new properties to my script - it works perfectly.
Thanks, as always for your help and quick response.
Derek