Topic: Master Detail form

Hello,
I am working on a application so the user can place an order with the suppliers for parts required. There is a form which is added per order and the form has an auto increment number which gives the Track number and this is the master. There is a Items table which has fields for TrackNumber, Quantity, PartNumber, Description, and Price. I place a TableGrid at the bottom of the master form and set it to display the fields from the Items table. This TableGrid is set so that it has AllowEdit and AllowCreate so the user can just enter the items required.
The user should be able to add items to the table and each line item record should have the Track number added so each master record has the correct line items. I would really like to display the quantity*unit price at the right hand end of each line and the sum at the bottom of the table.
I am having trouble getting this to work. Can anybody help please?
Thanks in advance,
David

Re: Master Detail form

Hello,
An update to this is that the client now wishes to have another window open to enter the line items one by one, instead of editing the items on the line. These items are not stored in an inventory or anything. I have added that window but having trouble still. I can attach the project if anyone can help at all please.
Thanks,
David

3 (edited by derek 2017-08-03 12:46:05)

Re: Master Detail form

Hi David,
If you could attach your project, it might help to highlight any issues.
In the meantime, I took an old project and changed it to be more in line with what you described.  Is this roughly the sort of thing you're meaning?
Regards,
Derek.

Post's attachments

Attachment icon radsoft form.zip 340.2 kb, 419 downloads since 2017-08-03 

Re: Master Detail form

Hello Derek,
thanks for the response. I have upgraded to MVD version 3.5 also so I hope that is okay for you. Please find the project attached. Ultimately I will need the software to be able to print a purchase order that can be printed and even emailed just so you know where this is heading. You should get the idea of what I need to do but please feel free to improve where I have mucked it up.
Thanks and regards,
David

Post's attachments

Attachment icon TrackBook.zip 348.85 kb, 417 downloads since 2017-08-04 

5 (edited by derek 2017-08-04 12:41:38)

Re: Master Detail form

Hi David,
Thanks for the project.  I made a couple of changes that I hope address the points in your original post and then made one or two alterations as they occured to me going through it.
1.  I added a relationship between the items and the purchaseorder tables so when you add items, it automatically adds the tracking number to maintain the relationship.  This works whether you add items at the same time as adding an order OR if you add an order, save it and then add items at a later stage.
2.  I changed the search comboboxes on the purchaseorderlist form to be incremental so the user doesn't have to click 'search' (now hidden).  This gave me some space so I added a 'clear all' button to save users having to clear  the combobox searches individually (I know, we spoil them too much!!).
3.  Branch was a combobox dropdown on the purchaseorderrecord form so I added it as a combobox search on the purchaseorderlist form as well
4.  I added running totals to all the tablegrids
5.  The 'total price' field on the item form now calculates automatically
6.  I added a couple of calculated fields so you can a) see what the running total of all 'tracks' is on the purchasorderlist form and also added a flag to show whether there are any notes.
There wasn't much to do in the script but where there was, I've commented it so you can easily change/remove it.
Hope some of the above helps,
Regards,
Derek.

Post's attachments

Attachment icon radsoft trackbook.zip 350.9 kb, 461 downloads since 2017-08-04 

Re: Master Detail form

Hello Derek,
thanks, I really appreciate your work on this. Sorry about the delay, my weekend was pretty well taken up. I appreciate what you have done here and you have interpreted my needs correctly.
Best regards,
David

Re: Master Detail form

Hello Derek and Dmitry,
I am not sure but there is possibly a bug for Dmitry to look into. Derek very kindly worked on my project which I attached and his solution is good, thank you Derek. Derek put a sum for the finance column on the two grids that appear on the two main forms and as he is in UK he put the pound sign. I downloaded the project he worked on and replaced the two sum fields with $ as the text in the sum fields. It seems okay but then it changes back to the pound sign again all on its own. I didn't really believe it but it has done the same thing a number of times for me. I expect Derek has a pound sign on his keyboard but I need to use the $ sign.
I did the original work using version 3.4 and then upgraded to version 3.5 and that is the version that Derek looked at.
Dmitry, is there something I can do to rectify this.
Thanks to both of you.
Regards,
David

Re: Master Detail form

David,

Make sure you place the $ sign in both the tablegrid settings and the Search button settings. I tested it and it works fine.

Re: Master Detail form

Hello ehwagner,
thanks. I thought I did both but maybe not. I can't see how to left justify the numeric columns. Do you know if that is possible?
Thanks again,
David

Re: Master Detail form

radsoft wrote:

Hello ehwagner,
thanks. I thought I did both but maybe not. I can't see how to left justify the numeric columns. Do you know if that is possible?
Thanks again,
David


Example

procedure Form1_TableGrid1_OnChange (Sender: string);
begin
    Form1.TableGrid1.Columns[0].Alignment := taLeftJustify; // for first column
end;
Dmitry.

Re: Master Detail form

Morning David,
Please see attached for a couple of worked examples.
To right justify tablegrids for numeric columns, you only need to align the header (the column values and the footer take their alignment from the field definition (in this example, currency)).
To left justify tablegrids for numeric columns, you need to align both the column values and the footer.
.
Morning Dmitry,
Can the column header alignment be automatically set to right justify - the same as the column values and the footer for integer, currency and real fields, so that it doesn't have to be done by script?
.
Regards,
Derek.

Post's attachments

Attachment icon radsoft justify.zip 337.08 kb, 436 downloads since 2017-08-14 

Re: Master Detail form

Hello Dmitry and Derek,
thank you both for the answers and support. Is there any way I could have found that justification information myself from any documentation?
Really appreciate your help.
Regards,
David

Re: Master Detail form

Morning David,
Most of the time, I just use the 'search' button at the top of this forum page, type in something like "justify" or "align" or "alignment" and see what comes up.  It can be a bit hit and miss but in a strange way, that can help as well as you sometimes come across other things that you didn't realise you could do (I know, I need to get out more!).
Another way might be to look at the object properties.  I know in your 'tablegrid column justify' question it doesn't directly help, but there is an object property for edit fields called 'alignment' with values of 'taleftjustify, 'tacenter' and 'tarightjustify'.  So I'd probably then knock up a line of script and just see if it also worked with columns.  Occasionally, you strike lucky.
Derek.

Re: Master Detail form

Hello Derek,
I frequently look at the help file created by The Engineer as it is very helpful. I wonder if it will be updated and expanded at all??
Regards,
David