2,101

(2 replies, posted in General)

Hi Adam,
I suspect your script is trying to retrieve supplier details using the id of the product rather than using the id of the supplier. 
It just happened to work (for the wrong reasons) for Products 1, 2 and 3 because you have Supplier 1, 2 and 3 to (incorrectly) join on.
See attached which should fix it.
Derek.

Hi David, Thierry,
Please find attached what I think / hope is a fixed version of your project.
From what I could tell,
1.  it didn't (for some reason or other) like formquickselect.tablegrid1 so I just deleted it and recreated it and it was okay.
2.  as Thierry pointed out, the sqlquery needs to have the record id in the 'selection', even if you then do not display it in the grid (to hide it, at the end of the sqlquery column headings, use 'delete_col').
3.  the memo field in formmedical was set to readonly.
And I think that was all that needed changing.
My earlier suggestion of adding Form1.TableGrid1.dbPopupMenu.Items[0].Enabled := False;  to the script wasn't necessary after all.
You could have also defined formquickselect.tablegrid1 in the usual way (with select columns etc) so that when formquickselect is first called, you see ALL records (rather than a blank screen as it currently is which can be a bit disconcerting).  At that point, you then click on your 3 buttons to perform your various sqlquery calls to filter the data.
Hope this moves you on.
Regards,
Derek.

Hi David,
Been a while - hope all is well.
I've used sql query buttons quite a bit and the only thing I can suggest you try is to add the following bit of code in your script, right at the very end (between the concluding 'begin' and 'end') - and obviously changing the form and tablegrid names to suit your application.

begin
  Form1.TableGrid1.dbPopupMenu.Items[0].Enabled := False;   
end.

If that doesn't work, can you attach your project (or a cut down version if it's business sensitive) and I'll try and have a look.
Regards,
Derek.

2,104

(28 replies, posted in General)

Hi Adam,
I've used this sort of flashing effect before (visible / invisible) - see attached.  I imagine you could do something similar with colours. 
However, my experience tends to be that too many 'disco lights' (LOL!) can end up annoying users!
Derek.

2,105

(28 replies, posted in General)

Adam,
Just one small change to Item 2 - to help the user, you might also want to keep a running count of how many characters are in the message (see attached).
Derek.

2,106

(28 replies, posted in General)

There are different ways but I'd use 'gettextlen'.
If the entered text is greater than will fit in your label, you can show a message or, as I've done in the example, simple hide the 'save' button until the text length is reduced to the permitted length.
Derek.

2,107

(28 replies, posted in General)

Does something like this give you what you want? (just item 2 from your post).
form1.labelfinished.caption := sqlexecute('select message from messages order by random()');
Derek.

2,108

(28 replies, posted in General)

Hi Adam,
At its most basic, I'd use a table (messages) with 2 columns - 1 column for the message itself and 1 column to hold a flag to say whether it's to be used or not..  If you're talking multi-user, you could link it to a userid table so that each user had their own set of messages (useful in a multilingual environment) - I guess it really depends how far you want to take it.
With message length, I'd just use the column heading in the tablegrid to inform users that the maximum length of message is NN - but, you could do the job more thoroughly and trap for input greater than NN characters and display an error message.
As always with MVD, probably lots of other ways to do it too.
Derek.

2,109

(28 replies, posted in General)

Hi Adam,
In your Form1_onshow, I'd probably go with
  form1.cbhours.itemindex   := 0;
  form1.cbminutes.ItemIndex := 0;
  form1.cbseconds.itemindex := 0;
You could also set form1.cbseconds.itemindex := 1; and use the same code to prevent the clock going negative (it wouldn't stop the user from deliberately doing it - for whatever reason - but would prevent it accidently happening).  Please see attached.
Derek.

2,110

(28 replies, posted in General)

Hi Adam, Nrmuduli,
Not had time to go through the script but I imagine a 'not valid integer' error message would occur when you run it without having selected a time from the comboboxes (ie blank hours, blank minutes and blank seconds) which should be easy enough to trap. 
Running it with 00 hours, 00 minutes and 00 seconds (rather than blanks) stops the 'not valid integer' message but then takes your counter into negative (again, should be easy enough to trap).
Regards,
Derek.

2,111

(28 replies, posted in General)

Hi Adam,
I'm not sure if this is the sort of thing that you're after (please see attached).  I've bolted it together from bits of old code from other projects.  It doesn't have all the 'bells and whistles' that you probably want (for example, changing colour schemes - nice one EHW) but the core functionality is probably okay.  And it will need some validation checks putting in at some stage.
Anyway, maybe it will give you some ideas?
Regards,
Derek.

2,112

(25 replies, posted in General)

Hi Adam,
I haven't actually tested it but on first glance, shouldn't line 131 in your 'watchexecute' procedure be
Hrs := (ElapsedTime  div 3600000) mod 60;     (it was previously 6000000).
Derek.

2,113

(3 replies, posted in General)

Hi Adam,
Perhaps I'm misunderstanding your question but is there any reason why you don't want to set the button's default enabled state to 'false'' in the button's object properties instead of scripting to disable it when your form is first shown?  Then you'd only need the one statement in your script - something like

procedure Form1_TableGrid1_OnClick (Sender: TObject);
begin
  if form1.tablegrid1.SelectedRow > -1 then form1.button2.enabled:= true else form1.button2.enabled := false;
end;

(although you don't really need the 'else.......' because once you start working with your grid, there will always be one of the rows that is highlighted).
Derek.

2,114

(25 replies, posted in General)

Hi Adam,
I did something like a stop-watch a while back.
In my example, the stop watch starts as soon as you enter the number of seconds and similarly, it is reset when the number of seconds are deleted so I appreciate that it's not exactly as per your attachment but you should still be able to take the code for the basic stop-watch functionality and apply it to your project.
Hope it helps to move you forward.
Regards,
Derek.

2,115

(10 replies, posted in General)

Hi Adam,
There is always going to be some lag unless you go down the route suggested by EHW;  the point was that the lag to load frmsplash is noticeably REDUCED  by moving the splash screen call from the form1_onshow procedure and placing it between the 'begin' and 'end' when the application loads.
It's standard MVD that when you leave the label captions blank, they do not show by default when editing the frmsplash form.  Just click on the relevant label in the 'controls' tab (see screen shot) and its outline will be displayed thereby allowing you to edit it (it's just like when you have objects that are in the background behind other objects (ie a label behind a panel) when designing your forms and you need to 'edit' them without moving the foreground object).
Derek.

2,116

(10 replies, posted in General)

Hi Adam, EHW, Jean,
I believe the original issue was that you'd put your splash form within the form1_onshow procedure rather than on launch (ie between the final 'begin' and 'end' of any script.
If you use the TTimer approach, you still need to have an idea of how many seconds your slow-loading app is going to take, in which case you might just as well stick with the 'sleep' instruction in your script as you were already doing (in your example sleep(7000) using EHW's timings).
With any of my slow loading apps, I use a splash screen with the sleep command and use the time to pop up different messages while waiting for the application to load (ie name of the app for a couple of seconds, then the author for a couple of seconds etc etc).  It doesn't reduce the overall load time of the application but at least the user doesn't think it's stopped running!
Please see the attached for the sort of thing I'm meaning (I've used a simple timer in this example rather than different timed messages but the principle is exactly the same).
Hope this helps,
Regards,
Derek.

2,117

(9 replies, posted in Script)

Hi Vasco,
There may be some specific reasons why you can't do it this way - but rather than use 2 tables (pre-invoice and final-invoice - both presumably with a similar structure), could you not have just one table (invoice) and then use a status indicator to show if it is pre-invoice or final-invoice (or any other status you may want)?  The attachement is a very quick example of how it could work.
Just a thought.
Derek.

Hi Vasco,
Is this the sort of thing that you want? (please see attached).
It uses a calculated field to join 3 fields (first name, last name, town) together so that the calculated field can be used as the search field to find rows of data in the table that match on any of the fields.
Regards,
Derek.

2,119

(5 replies, posted in General)

Hi Adam,
Not sure without seeing your project, but attached is (I think) what you want.  If you want it to beep when the combobox is empty rather than contains a value, just reverse the condition in the script.
Regards,
Derek.

2,120

(5 replies, posted in General)

Hi Manix,
Probably more than one way but I've always done it like this (see attached).   
In this example, I've associated a beep with a button click but you can attach it to any action, calculated result etc.
Hope this helps,
Derek.

2,121

(9 replies, posted in General)

Hi Adam,
If I understand this correctly, you could perhaps approach it as per the attached.  Probably lots of other ways too but this seems pretty straightforward.
Regards,
Derek.

2,122

(3 replies, posted in General)

Hi Adam,
You could try setting  BorderIcons / biSystemMenu = false as an object property of the form (although that also hides the minimise and resize icons).
Additionally, you could also hide the file menu options as well (if you're going totally minimalist) with a script but you need to remember to include a button to close the form otherwise you have to kill it from within the task manager!
Please see attached - if you want to show the file menu options, just get rid of the script.
Regards,
Derek.

2,123

(5 replies, posted in General)

Hi Adam,
Probably the most straightforward way (in other words, the one I prefer - LOL!) would be as per the attachment.
However, this will only work if the two tablegrids are sorted in the same sequence (in your example, as they are both basically the same, I can't imagine that they wouldn't be).
Hope this helps,
Derek

Hello JB, Mcsimm, Sign2,
I think whether it is 0 days or 1 day perhaps depends on the context of the project. 
For this project, to be admitted and then discharged on the same day is 1 day, not 0 days.
I have changed my script to force days to show as whole numbers (no decimals) which may have caused some confusion.  Also, both dates must now be 'ticked' before the calculation is performed and there is a simple check for discharge date being >= admission date.
Derek.

Привет, Sign2
Возможно, это также так
Derek.