1 (edited by reteinformatica 2019-02-07 14:10:42)

Topic: Strange behavior in a form

Hi everyone,
I have a problem that I just can not solve: 'frmSupplier' has a button (AGGIUNGI NUMERO) that should open 'frmArrivomerce' but instead of opening this form it gives me this error "table Anagraphic has no column named 'Arrivo'" which is true but I do not understand why it gives me this error. From all the tests I have done I understand that it opens only if I remove both datapickers.
I attach the project, if someone is kind enough to give it a try. Remember that I use version 1.44
Thank you all.

Post's attachments

Attachment icon SuperGulp.zip 328.95 kb, 56 downloads since 2019-02-07 

2 (edited by derek 2019-02-07 17:52:23)

Re: Strange behavior in a form

Hello Reteinformatica,
The error message is correct.
The problem is that on 'frmfornitore' you are trying to add / save fields that belong to 2 tables - 'anagrafica' and 'data'. 
But the 'save button ('salva') can only save to  one table - you have configured it to save to table 'anagrafica' and  it is unable to save 'arrivo' and 'scadenza' to table 'anagrafica' because they belong to table 'data'. 
And this is why you get the error.
Regards,
Derek.

Re: Strange behavior in a form

Thanks Derek you are very kind. So is the only solution to put every field in one table?

4 (edited by derek 2019-02-07 22:26:21)

Re: Strange behavior in a form

It depends on what you are trying to do.
If there is a 1:1 relationship between the 'anagrafica' table and the 'data' table then you would normally hold 'arrivo' and 'scadenza' in the 'anagrafica' table - there is no need to have 2 separate tables.
If there is a 1:many relationship between the 'anagrafica' table and the 'data' table, you would normally add / save the fields belonging to the 'anagrafica' table on one form and then add / save the fields belonging to the 'data' table on another form.  The relationship between the 'anagrafica' table and the 'data' table is specified in your 'data structure and the link between the two forms ('frmfornitore' and 'frmarrivomerce') is through 'frmfornitore.tablegrid1 (MVD does this automatically for you).
If I understand the aim of your project, it looks like you have a 1:many relationship between 'anagrafica' and 'arrivomerce'.  If this is correct, then it makes more sense to hold 'arrivo' and 'scadenza' on the 'arrivomerce' table (and you can delete the 'data' table).
Anyway, have a look at the attachment and perhaps it will give you some ideas (I have done it in MVD 1.44 so you should be okay).
Derek.

Post's attachments

Attachment icon SuperGulp.zip 342.67 kb, 53 downloads since 2019-02-07 

5 (edited by reteinformatica 2019-02-08 14:52:27)

Re: Strange behavior in a form

Thanks a lot for the correction and detailed explanations.
Sorry if I ask you another question: How do i print the report I put in the project by inserting the data of the selected line in the Tablegrid? Even if I select one it puts me in the report always the data of the first record. Thank you.

6 (edited by reteinformatica 2019-02-08 14:52:37)

Re: Strange behavior in a form

This I think you have solved it: I set as "components involved in the search" only the Tablegrid, seems to work, I hope I did it in the correct way.

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=5053

Post's attachments

Attachment icon Cattura.PNG 5.52 kb, 22 downloads since 2019-02-08 

Re: Strange behavior in a form

That's not true, it doesn't work. It appeared to work but it doesn't work that way.

8 (edited by derek 2019-02-08 20:22:35)

Re: Strange behavior in a form

Hello,
I don't use FastReport but I've had a look and I think you do it this way (see attached).
You must highlight the row in the grid and then click  'stampa' to print out the 'customer' on the report;  when you click another row and click 'stampa' it should print out a different 'customer' etc etc.
If you want to print all the rows at the same time, I think the report needs to be coded differently (perhaps with each 'customer' in a different report 'group header'?  (but I may be wrong)).
Sorry, I may have changed some of your report while I was looking at it, so you'll need to check the layout etc.
Derek.

Post's attachments

Attachment icon SuperGulp.zip 345.63 kb, 53 downloads since 2019-02-08 

Re: Strange behavior in a form

Yes it works, that's just what I wanted, select a record from the Tablegrid and print the data of the selected record. I just didn't understand what you changed to make it work.
Thanks always so much

Re: Strange behavior in a form

Hello Derek

In a post, jou say : "I don't use FastReport ".
Well, how do you succeed to get any report ?
Do you use another method ?

Regards
JB

Re: Strange behavior in a form

Hi Jean,
What I meant was that I very rarely have the need to print anything out, so I don't consider myself a user of FastReport (or any other reporting tool). 
Derek.

12 (edited by reteinformatica 2019-02-11 12:30:23)

Re: Strange behavior in a form

Hi Derek,
If there is a record of the same customer going to print me print the first record of the customer regardless of which record I select. Only if I change customer then I print another record.
In the project I'm attaching you can see for example the customer with 3800 code, I made more than one registration. It create a report Always with "Arrivo Merce" number 20999.
I just miss this thing is then the project is finished but I can't find a solution.
You have to select a row in the tablegrid of first form and click on "Stampa" that is print in Italian.
Thank you.

Post's attachments

Attachment icon SuperGulp2.zip 332.99 kb, 48 downloads since 2019-02-11 

13 (edited by derek 2019-02-11 16:51:23)

Re: Strange behavior in a form

Hello,
I changed the 'main' table on the report from 'anagrafica' to 'arrivomerce' and moved the 'stampa' button to form 'frmarrivomerce' and that seems to select each 'arrivo merce' number correctly.
But I'm not sure if that is the best way to do it.  I will have a longer look at it if I have some more time.
One question - in the 'anagrafica' table, there is a field 'numerodocumento'.  This means that a customer cannot have more than one 'numerodocumento'.  Is that correct or can a customer have more than one 'numerodocumento'?
Derek.

Post's attachments

Attachment icon SuperGulp3.zip 346.48 kb, 52 downloads since 2019-02-11 

14 (edited by reteinformatica 2019-02-11 19:10:51)

Re: Strange behavior in a form

Hi Derek,
' NumeroDocumento ' of the table ' Anagrafica ' is relative to the ID of the document (identity card, driver's license, passport, etc.) so it's okay that there is only one.
The database is for a second hand market, whenever a customer brings something to sell you have to generate a contract, in the field ' Arrivomerce ' There goes the number of a document with the list of items that sells generated by a management program. The Tablegrid in 'frmFornitore' is used to be able to add a number of ' arrivomerce ' each time different, because the same customer can bring things to sell several times and each time a new contract must be made.
Isn't there a way to take the data from the Tablegrid in the first form simply by selecting the line?
Your solution works but it is a bit particular how to get to print, especially for those who are not very practical computer. If I had to use it I wouldn't have been problems.

15 (edited by derek 2019-02-11 23:14:54)

Re: Strange behavior in a form

Hi,
Please try this version - the 'report' button is back on the 'frmstart' but the correct contract should now be printed when the relevant row in the tablegrid is selected.
Derek.

Post's attachments

Attachment icon SuperGulp3.zip 346.53 kb, 54 downloads since 2019-02-12 

16 (edited by reteinformatica 2019-02-12 21:41:17)

Re: Strange behavior in a form

Hi Derek,
The operation is good, there is only one problem: if in the form frmFornitore insert a customer without assigning a number of ' arrivomerci ' is not visible in the Tablegrid of the form ' Frmstart ' and is not even searchable.
It is important because once the program is finished I will enter a database of almost 1000 customers already existing but that do not have any number of ' arrivomerci ' so I won't see any of these customers even to search for them and assign the number of ' ArriveoMerci'
Button to print could be put even in 'frmFornitore' if it could be better, I don't know.
Sorry about all the trouble and thanks.

Re: Strange behavior in a form

Hi,
In frmstart.grdfornitore, you have fields from both anagrafica and arrivomerce - this is why, if there is no number for arrivomerce, they are not visible.
To get around this, I have split them into 2 tablegrids - one for anagrafica and one for arrivomerce.
The two tablegrids are linked with a search button (invisible) so when you click on a row in grdfornitore, it automatically shows all the arrivomerce rows for that client.  Personally, I think this is a much better way to show the information as it avoids all the duplication you had before.
Then all you need to do is click on the arrivomerce that you want to print and the report runs (the stampa button is also hidden);  this makes the process a bit quicker for the User.
I think this solves the issues that you have identified.
Regards,
Derek.

Post's attachments

Attachment icon SuperGulp4.zip 350.49 kb, 48 downloads since 2019-02-13 

Re: Strange behavior in a form

I don't know how to thank you Derek! There would be this little problem: in the report I reverse the Counter field with the contract number, in the upper right corner, with the customer code though it would seem that the two counters are placed in the right place (record_count_1 of the table ' ArrivoMerce' at the top Right and record_count of the table ' Anagrafica ' first field in the report, under the heading "Codice Cliente").
I could just reverse the two fields in the report but I'd like to understand why it does.
I've done some testing in your project, but I can't figure it out.

Re: Strange behavior in a form

Hi,
In FastReport, it does not use tablename+fieldname, it uses 'report' +  fieldname (eg, report.indirizzo, report.telefono etc). 
Because you are using anagrafica.record_count and arrivomerce.record_count, this would cause a duplicate in FastReport, so it names them report.record_count, and report.record_count_1. 
It depends on the sequence in which you select fields from the database in MVD - if arrivomerce.record_count is selected before anagrafica.record_count, then it becomes report.record_count.  If you select anagrafica.record_count first, then that becomes report.record_count instead etc etc.
Please have a look at the attachment (in the screenshot, I show that I have changed the sequence of the two fields) and see how the change of sequence now affects the report.
Derek.

Post's attachments

Attachment icon supergulp4.zip 527.44 kb, 43 downloads since 2019-02-13 

Re: Strange behavior in a form

Ah OK, this simple thing was enough. It seems to work everything properly. Now I will study your project and apply what I understand in my, because I do not just have changes but I like to understand what should be done and learn. Once sold my program I will also buy the license because I'm going to use this wonderful program for future work.
If I log into something during the changes to my project I will come back to ask.
Thanks Derek, I really don't know how to thank you.

Re: Strange behavior in a form

Glad it's working now how you want it to.
Attached are a couple of suggested cosmetic changes to your original program - it's more to show you the sort of things that you can do with MVD - it's very flexible.
Good Luck,
Derek.

Post's attachments

Attachment icon supergulp4.zip 384.88 kb, 52 downloads since 2019-02-13 

Re: Strange behavior in a form

Hi Derek,
reviewing your changes in my project I discovered another big problem: the dates of 'arrivomerce' and 'Scadenza' can not go to 'frmFornitore' because it would put me the date when the customer is created and not when the goods entered that among other things, it can enter several times and therefore with different dates.
So, following the study of your changes, I moved the date fields in the 'Arrivo'Merce' table instead of in 'Anagrafica' and entered the controls in the 'frmArrivomerce' form.
Then I made the appropriate changes to the properties of the various TableGrid and buttons.
I seem to have done everything correctly and that it works well.
Too bad I can not enter the checks for dates in the search form, but it's not a problem.
I enclose the project with the changes indicated.

Post's attachments

Attachment icon SuperGulp.zip 336.77 kb, 40 downloads since 2019-02-15 

23 (edited by derek 2019-02-15 14:20:14)

Re: Strange behavior in a form

Hi Fabio,
Now that your data is structured more logically (data.arrivo and data.scadenza in the arrivomerce table), there is no reason why you cannot search for the dates - you can have more than one search button on the same form.
In your project, one button searches anagrafica records, the second button searches arrivomerce records.  And, of course, you have the button that filters arrivomerce records depending on the row in your grdfornitore tablegrid.
And if you use the 'incremental search', the User does not even see that there is more than one search button, he just enters values in the search boxes and it is automatic.  Multiple search buttons can be very powerful (and if you are not careful, a bit confusing - LOL!)
Derek.

Post's attachments

Attachment icon SuperGulp5.zip 350.75 kb, 59 downloads since 2019-02-15 

Re: Strange behavior in a form

Thanks Derek very very very much. Now it seems to be perfect. Thank you also for styling corrections.