2,126

(3 replies, posted in General)

Hi v_pozidis,
You have taken Dmitry's basic phonebook application but changed the processing logic by placing the second tablegrid (to show the filtered search results) on the same form.  So, if you click in an empty space in the tablegrid, your search filter has nothing to restrict the answer by and will therefore return all rows.
The easiest way to prevent this might be to give focus to the table as soon as the form is opened so that the filter can never be blank.
Please see attached.
Derek.

2,127

(3 replies, posted in General)

Hi v_pozidis,
Not sure what happened to the attachment - it was there earlier.
Anyway, I have attached it again.
Regards,
Derek.

2,128

(9 replies, posted in Script)

Hi EHW,
I had a look at this problem but was going for the no-script option as always (only joking!).
It's a neat solution - nice one.
Derek.

2,129

(3 replies, posted in General)

Hi Terry,
Yes, that's not a problem.  The only thing you can't copy is the form itself so what I find easiest is
1.  create a new form with the same dimensions as the form you want to copy from
2.  on the source form, hold the shift key and then click on all the objects you want, then right-click and choose copy
3.  on the target form, right-click and choose paste
4.  at this point, all objects are still 'selected' so you can move them all together so they are placed precisely where you want them.
Sometimes I find one or two objects have 'moved' or get placed behind other objects so you might need to do a bit of fine-tuning.
It's important to remember that it is not just the source object that gets copied, but all of the properties associated with the source object (definitions, colour settings, tab index, visibility etc etc).
I find it useful in these situations to create a form and immediately place a panel on the form that is the same size as the form.  Place all your objects as you need them on the panel.  Then, if you need to create a copy of the form, all you need to do is right-click on the panel and the panel AND ALL OF THE OBJECTS on the panel are automatically included - one click to copy everything!  It's a big time saver. 
Please see attached which just demo's the above points.
Regards,
Derek.

2,130

(1 replies, posted in General)

Hi Knobby,
If the two tables are linked, the easiest way is to check it against a combobox;  in your example, if it's not in your "parts" table, then it won't be displayed in the combobox.
However, if there are a large number of entries in the combobox, it can be a bit time consuming scrolling up and down for the correct entry.  In this case, there are a couple of options that I could think of.
Option 1 (no script)
With the cursor in the combobox, start typing the part no' and the combobox will highlight all those values that match what you have typed.  This seems the most straightforward way to me but it doesn't allow for wildcards (ie it is a 'left to right' match of what you have entered).
Option 2 (with script - but not much!)
Use an edit field to build a combobox on the fly, depending on what you type into that edit field.  In this example, I'm allowing for wildcard searches so what you type in can appear anywhere in the part no'.
In both options, the combobox is a concatenation of the part no' and the part description (for extra visual validation) but it doesn't affect the searching.
Please see the attached and hopefully it will give you some ideas.
Regards,
Derek.

2,131

(8 replies, posted in SQL queries)

Hi,
I've just downloaded it and tried it and it's okay for me.
What error message are you getting when you try to run it?
Derek.

Hello Mcsimm,
извините, но я не говорю по-русски - но, возможно, вы можете попробовать что-то подобное.
пожалуйста, изучите пример, который я включил.
(Sorry but I don't know much russian but maybe you can try something like this.  Please read the example I have included).
Derek.

Hello Mcsimm,
You can not use a calculated field in another calculation.
вы не можете использовать вычисляемое поле в другом расчете.  вместо этого попробуйте
summary.rate * (summary.currReading - summary.PrevReading)
Derek.

2,134

(7 replies, posted in General)

Hi Adam,
Not sure why you want to script it?  Seems a lot more straightforward just to use the filter on the combobox object properties (see attached).
Derek.

2,135

(2 replies, posted in Script)

Hi Tobias,
Please have a look at the attached example as being a very straightforward way of doing it (storing the original record values in local edit fields).  There are probably other ways too.
Hope this helps,
Regards,
Derek.

2,136

(2 replies, posted in General)

Hi Manix,
If you show details from two different tables that have a one : many relationship (in your example, suppliers and orderhead) on the same tablegrid, you will always get repeating data.  It's not like a spreadsheet (like Excel) where you can group the data according to a chosen column.
What I'd suggest,if you want to avoid repeating data, is that you use 3 tablegrids (one for suppliers, one for orderheads and one for orderlines) and link the three tablegrids together (please see attached).
I've not had time to test it so if this approach is any use to you, you need to give it a good testing.
Regards,
Derek.

2,137

(3 replies, posted in General)

Hi Manix,
It's almost the same syntax as for coloring the column (but obviously, you don't need to loop through the rows);  here's an example
form1.tablegrid1.columns[1].footer.color := clred;
Regards,
Derek.

2,138

(34 replies, posted in General)

Hi EHW,
Thanks.  As always, I was trying for the zero-script option but had to admit defeat in the end - LOL!
Derek.

2,139

(34 replies, posted in General)

Hi Adam,
Not sure if something like this helps on a couple of the points you raised.  As always, probably other(better) ways to do it.
Regards,
Derek

2,140

(34 replies, posted in General)

Hi Adam, Hi EHW,
After you mentioned in a previous post that everything that comes in on one purchase invoice goes out on one sales invoice (so a strict 1:1) but that there can be a number of adjustments (refunds) against the original purchase invoice, it seemed to me (unless I'm missing something) that from a data design point of view, the simplest thing would have been to hold both purchase and sales information on one single record.  Then you don't have to worry about creating additional records, maintaining links between related sales and purchases, leaving orphaned records, losing traceability  etc etc. 
Simplest is often the best if the design doesn't compromise functionality and I don't believe it does in this case.
Looking back over the history of this topic,  the options have gone from having separate tables for purchase and sales invoices, using the same table but with discrete purchase and sales records and now it seems you can use not only the same table but also the same record!
I haven't attempted to replicate all of the functionality of your existing project but I'm pretty sure that it's possible using the above suggested schema. 
I've knocked up a quick demo to prove some of the more basic functionality - the whole thing can actually work without any script at all (always my target!):  the few lines of script that I've used are only cosmetic, to make it a bit more user friendly.
I appreciate that you and EHW have done a lot of work on this so it's possibly too far down the road to want to change now, but it might yet prove to be of some use.
Regards,
Derek.

2,141

(5 replies, posted in General)

Hi Manix,
If I understand you correctly, you don't actually need to use a calculated field to concatenate the two columns;  when you define the combobox on your form, you simply specify the relationship and then instead of choosing one field, you enter {field1} {field2} etc etc.  And you can add any text you want before, in the middle or after your fields.  Please see the attached for some examples.
With regard to aligning the combobox fields, I'm sure there is a clever way of doing it but I do something more simple.  I add another field to my lookup table where my tax rates are held and align everything there.  So when you come to use the combobox on your form, this is the field that the user sees and it looks as you want it.  Again, this is in the attachment.
Hope this helps,
Derek.

2,142

(6 replies, posted in General)

Hi Nitin,
I believe the correct syntax is:
      if Scheduling.combobox9.dbitemid = 1 then Scheduling.CheckBox1.Checked := False else Scheduling.CheckBox1.Checked := true;
etc, etc.
Regards,
Derek.

2,143

(34 replies, posted in General)

Hi Adam,

The reason I'm converting purchase inv to sale inv rather than having them separately is that this part of the project involves 1 product transactions hence there is no qty field. In and out.

I'm not sure if I understand this part of your post.  Ignoring the question of purchase refunds for the moment, do you mean that on this particular project, everything that comes in on 1 purchase invoice then goes out on one sales invoice?
Derek

2,144

(4 replies, posted in General)

Hi Vasco,
Please see the attached which may give you some ideas.  I wasn't sure if you meant the id in the table or the rowid in the tablegrid so I've shown both, just in case
Regards,
Derek

2,145

(34 replies, posted in General)

Adam,
It's your project so I don't know the finer details of how it works but it seems to me that you can:
1.  add a purchase
2.  add a refund for that purchase
3.  sell that purchase
Selling the purchase deletes it from tgmainpurchinvs and adds it to the tgmainsalesinvs.  But it leaves the refund record behind in tgmainpir.
That's how you get more records in tgmainpir than in tgmainpurchinvs and that is going to happen irrespective of whether you use EHW's suggestion, my suggestion or anyone else's.  That's my point.
For what it's worth, in my opinion there are a number of design questions to be addressed before you need worry about any of the above coding issues, the MAIN one being the way in which you delete a purchase record when you sell it - you lose all traceability back to the purchase record which, from both a commercial and an audit point of view, could be a big problem. 
Derek.

2,146

(34 replies, posted in General)

1.  The 'edit' and 'delete' buttons are hidden when the 'all refunds' button is clicked and redisplayed when the user clicks back in the PI invoices tgrid (see attached screenshot).  Anyway, it's moot as EHW's sqlquery approach tackles the problem more at source rather than simply trying to side-step it and allows editing directly from the 'all refunds' grid which is more functional.
2.  Your design allows for multiple refunds against one invoice, therefore it is quite normal for the PIR refunds tgrid to contain more records than the PI invoices tgrid  - so I am struggling to understand why this is an issue?  And both suggestions (the 'display only' grid approach and the sqlquery approach) behave in the same way and show the correct number of refunds, as far as I can tell.

2,147

(34 replies, posted in General)

Hi Adam,
The problem with trying to edit a refund directly from the 'all refunds' grid is that it you haven't highlighted a record in the 'invoices' grid  in the first place (as you would normally do to see refunds for a specific invoice) and so you can't easily get the tax rate (which is only held on the invoice and not on the refund - sounds familiar!).  You'd need to do a double read - once of the refund record to get the associated invoice and then read the associated invoice to get the tax rate.
This problem largely goes away if you don't show the tax rate on the refunds form (and as stated before, I'm not sure why you need to, bearing in mind it can't ever be any different).
Given the above, I think the most straightforward option is the 'hidden grid' which is visible when you click 'all refunds' (and which also hides the 'edit' and 'delete' buttons);  in effect, it becomes a display only 'all refunds' grid.
Derek.

2,148

(34 replies, posted in General)

Hi Adam, EHW,
With regard to your issue with the 'all refunds' button, it stops working once you've viewed or edited a refund (viewing and editing invoices is fine).  To get the 'all refunds button working again, you either have to restart the program OR click on an invoice that doesn't have any associated refunds, so something is not getting cleared properly.
But I'm not sure why you need a 'search' associated with the 'all refunds' button if you're displaying everything.  A 'quick and dirty' way that I could think of was simply to add a hidden grid that is displayed when you click on 'all refunds' and hidden again when you click back in the invoices tables (see attached).  But there's probably a 'proper' way to do it which I'll try and have a look at.
Just a word of caution, but with possibly 3 of us looking at it independently, you need to be careful that we don't end up overwriting each others' changes.
If I get time, I'll have a think about  the other 2 issues you mentioned as well.
Regards,
Derek.

2,149

(34 replies, posted in General)

Hi Adam, EHW,
I've added two lines to the script (234 and 305) which I think addresses the issue you were having.  Hopefully, it doesn't mess anything else up that you've been working on.
I haven't made the same changes for the cbpirtaxpi, cbpirtaxrate, cbsirtaxratesi and cbsirtaxrate fields on the amend purchase refunds and amend sales refunds form as I don't understand why you need to show them;  they aren't saved to the refund table, therefore presumably they must be the same as the cbpirtaxrate field which is already being displayed.  So wouldn't it just be 4 unnecessary calls that will slow things down a bit?
Maybe I'm missing something (wouldn't be the first time - LOL)!.
Regards,
Derek

Hello Nitin,
I had a quick look at your project and made a couple of changes.
I don't like using checkboxes as filters because it's not possible to 'unselect' them (once you tick a checkbox, you see records with a value of 'Yes', when you untick a checkbox, you see records with a value of 'No' - but how do you then see records that are either 'Yes' or 'No'?  As I understand it, the only way is to exit the query and start fresh so it's not very user friendly).
So what I have done is to take the checkbox values from your 'course' form and used them to populate equivalent comboboxes that can be used as filters (so you can select 'Yes', 'No' or either from the comboboxes).  Doing this also seems to fix your other issues too.
I also added a 'clear all filters' button (because I was getting tired of resetting them all the time when I was testing - LOL!!).
I hope this is closer to what you want to achieve.
Regards,
Derek.