2,301

(5 replies, posted in FAQ)

Hello Frehak,
Please see the attachment which I believe solves your problem.
In your project, you have correctly created 2 relationships between the 'overview' table and the 'part' table (one for 'part A' and one for 'part B').   
In MVD, the description of the part in the first relationship (Part A) is retrieved into the tablegrid without any additional work. 
However, you have to manually retrieve the description of the part in the second relationship (PartB) (and for any further relationships). 
The easiest way to do this is to use a 'calculated field' with an sql statement to retrieve the description. 
Have a look in your 'overview' table at the calculated field 'cfpartB' that I've created and you will see how this is done. 
I have then included the calculated field in form1.tablegrid4 and it now should display as you want.
I hope this helps.
Derek.

2,302

(5 replies, posted in FAQ)

Hi and Welcome to MVD,
Here is a link to a project that Dmitry (the writer of MVD) put together to demonstrate many-to-many relationships.
http://myvisualdatabase.com/forum/viewtopic.php?id=1429
It might answer some of your questions.
If not, just post another question and I'm sure there will be someone who can help.
Regards,
Derek.

2,303

(5 replies, posted in General)

Hi Adam,
I did it as below (probably not the cleverest code on the block!):
Declare a variable (vkey: integer) and then change your script to the following:
Form1.dbiSearchDetCustImage.Clear;
vkey := sqlexecute('select id_customers from invoiceheader where id =' +inttostr(form1.tgSearch_Invoices.dbitemid));
Form1.dbiSearchDetCustImage.LoadFromDatabase('Customers', 'image', vkey);
The above code is in the attachment but you might just want to cut and paste the above if you've made other changes in the meantime.
Derek.

2,304

(5 replies, posted in General)

Hello Adam,
Please find attached your project with the problem (as I understand it) fixed.
In your original script, you were trying to retrieve the customer details using the key of the invoiceheader table from the invoiceheader grid. 
What you need to do is get the foreign key (id_customers) off the invoiceheader table from the invoiceheader grid AND THEN retrieve the customer details using the foreign key value.
In effect, what you are doing is a 'nested select' (I'm sure there's a technical term for it!!).
Have a look at the sections that I've changed and I think you'll see why it wasn't working.
I may have missed some other bits that you might have to fix but the principle (and the code) is exactly the same.
Regards,
Derek.

2,305

(23 replies, posted in General)

Hi Adam,
I always use a simple copy command that runs automatically whenever an application closes (seemed safer than rely on Users remembering to do it).  It's just 1 line in a script.
I'd be the first to admit that it's pretty simple (but just because it's simple, doesn't mean it's no good!) and it doesn't attempt to automate a 'restore' - that would need to be done manually.  But for the projects that I write, anything more complex would be overkill.
Maybe it gives you a couple of ideas to get you started.
Derek.

2,306

(13 replies, posted in General)

Hello Adam, EHW,
I was looking at your password issue again and trying to use standard MVD as much as possible.
So I've gone with using the usual tablegrid / edit forms for the users / passwords.  This allows you to have more than one user (which you said earlier was something you might want) and adding, changing and deleting needs no additional code.
And to reduce the script, I've used text hint functionality to reveal the passwords - just hover the mouse over the asterisks.
It's a different approach and might give you some ideas.
Derek.

2,307

(13 replies, posted in General)

Hi Adam,
In the attachment, I've cut and pasted the code I usually use in my projects.
When the program is run for the very first time, there will obviously be no valid users so part of the script creates the first user automatically - the username in the attached example is 'adam' and the password is 'mvd' (but this initial setting can be changed in the script). 
Alternatively, you could leave that portion of the code out of the script entirely and just create your first user directly in the table using something like 'sqlitestudio'.
My example allows for more than one user to be created but works just the same with one user if that's what you want.  I wouldn't advise it as I think it will create problems if the only login details to your project get forgotten - but it's just my opinion.
Derek.

Dmitry,
That's good news.  I shall go ahead and upgrade.
Can you send me the link to the page where MVD Version 3 is available for the discounted price?
Thanks.
Derek.

Good Morning Dmitry,
Thank you for your reply.
I have downloaded 3.11 Beta and the .BoldDays function works well - it will be very useful.
Is the discount for MVD Version 3 still available?
Regards,
Derek.

2,310

(31 replies, posted in General)

Hello Bulutsuzgece,
'Tablename'/'Fieldname' are not properties of COMBOBOX objects, they are properties of EDIT, MEMO and DATETIMEPICKER objects and can be selected from a dropdown list after you have defined your tables and fields (in the database tab of MVD).
'Foreignkey'/'Fieldname' are properties of COMBOBOXES and can be selected from a dropdown list after you have defined your RELATIONSHIPS between tables in the database tab of MVD.
If nothing is showing as selectable, this is because you HAVE NOT DEFINED any relationships between tables.
Creating relationships between your tables should correct this.
Derek.

Hello Dmitry,
I have a simple application for appointments, to-do lists etc.
I have 2 questions.
1.  My form is sized so I can see an entire year (january - december).  Is it possible to click on 'next' and see all of the next year.  At the moment, it scrolls one month at a time (please see screenshot1 in the attachment).  Something like a 'yearcalendar' object instead of a 'monthcalendar'.
2.  Is it possible to show on the 'monthcalendar' object when a day has an appointment or 'event' - for example, to circle that date or to show that date in a different colour or shading?
I am using MVD 2.8 / Windows XP (yes, I know!!!).
Thanks and Merry Xmas to you and your family.
Derek.

2,312

(3 replies, posted in General)

Hello Adam,
As always with MVD, different ways to do it - this is probably one of the simpler options (which is why I like it - LOL!!).
Regards,
Derek.

2,313

(6 replies, posted in SQL queries)

Hi,
Glad it helped.
I should also have mentioned that if you want the dates that you retrieve in your sql query to be in the same format as those in your other tablegrid, you will need to amend your sql query to something like this

  strftime('%d-%m-%Y',stcl.stcl_ldd),
  strftime('%d-%m-%Y',stcl.stcl_compdt),
  strftime('%d-%m-%Y',stcl.stcl_nxtdd),

Regards,
Derek.

2,314

(6 replies, posted in SQL queries)

Hi Nrmuduli,
My sql is perhaps a bit different to yours but is this any help?
Derek.

Hello Kkalgidim,
You can define your tablegrid as normal with the columns you wish to see and any column totals. 
Your 'sql query' uses this definition to display the output and the totals will be shown as specified (see 'yesterday sql query' in the attachment).
Instead of an 'sql query', you could just use a simple 'search' (see 'yesterday search calendar' in the attachment);  this gives you flexibility to see expenditure for any day (not just yesterday).
I hope this helps.
Derek.

2,316

(13 replies, posted in General)

Hello All,
I know that it doesn't answer some of the questions about MVD internal messages not being in the localised language (error messages, warnings etc) but it is quite straightforward to create a multi-language application (with only a bit of extra work).  As always with MVD, there will be many ways to achieve this but attached is a small application that I made to see how I might do it.
Basically, I just overlay panels on each form (one panel per language - I have used french and english in my example).  It is quickest to get everything as you want it to look on one panel and then copy and paste the first panel (all the objects on the panel are automatically included) to the second panel and then just change the labels, text hints etc.  Then for each form, you set which panel should be visible by script, depending on the language chosen.  Using panels keeps the script simple.
My example is very basic but it perhaps shows what can be done and gives people some ideas.
Derek.

2,317

(9 replies, posted in General)

Hi Adam,
This is the only thing that I could think of doing but there may be other ways that are closer to what you are trying to achieve.
Derek

2,318

(9 replies, posted in General)

Hi Adam, EHW and anyone else,
Please find attached one option for handling refunds (using just one table to hold both DB and CR transactions, as outlined by EHW). 
It's a clone of an old project so it doesn't look too much like yours but the principle of using either different tablegrids to split off invoices and credit notes (refunds) or (as I've done in this example) using the same tablegrid with a real-time filter, is basically the same. 
I prefer this way because it's quick and easy to set up and also means you can see ALL transactions, just DB transactions or just CR transactions all on the same grid - but you could choose to show 3 discrete grids all on the same screen if you wanted.
It's just 'play data' but it should work - the script is a bit messy but most of it is just for cosmetic reasons or better ease of use for users.
Hope this gives you some ideas.
Derek.

2,319

(9 replies, posted in General)

Hello Adam, EHW,
I'd been thinking about a similar approach and totally agree with EHW.  I might try
1.  deleting the CRSALEINVREFUND and CRSALEINVREFUNDITEM tables
2.  renaming (for clarity) SALEINV to TRANSACTIONHEADER and SALEINVITEM to TRANSACTIONITEM
This would simplify the structure greatly
3.  add a DB(debit)/CR(credit) indicator for each TRANSACTIONITEM record (with DB as the default)
4.  optionally add a 'REASON CODE' indicator (faulty, damaged, not required etc etc)
4.  use 2 tablegrids, filtered on the DB/CR indicator
With this approach,
5.  if the CR relates to an invoice, you simply add it as a new line to the existing invoice.
6.  if the CR is a general credit, it can be added as a totally new transaction unrelated to any invoice.
7.  from a reporting aspect, you could, for example, print out just the CR transactions if you need to issue a defacto Credit Note.
This option gives you greater flexibility but with simplicity - transactions that are wholly DB items, wholly CR items or a mix of DB and CR items - all using the same tables.
From a credit control point of view, it might also be useful to have an indicator against each TRANSACTIONITEM record to show if it's been paid, credit issued, in dispute etc etc (although in my experience, if one transaction item is in dispute, the entire transaction gets disputed - or maybe that's just how it works in the UK).
If I get a spare hour, I'll mock something up, as much for my own interest, to see how it might look.
Regards,
Derek.

2,320

(3 replies, posted in General)

Hi Adam,
Glad it helped.
The PC I was using when I replied earlier has MVD 2.4 which doesn't have the tablegrid 'show child records (if present)' feature.  When I saw your response, I remembered that you no longer need to use a 'search' button from MVD 2.7 onwards (I think) - d'oh!
So yes, the only issue was the missing table link.
Derek.

2,321

(3 replies, posted in General)

Hello Adam,
The ADD button isn't acting as EDIT per se;  rather, it's because:
1.  There is no SEARCH button on frmexpenses so all expense items records will be displayed (as per your 'show all records' setting in the tablegrid).
2.  It still wouldn't work properly as there is no relationship between the expenses table and the expenses items table.
Please see attached.
Derek.

2,322

(5 replies, posted in Script)

Hello Again,
Realised that in my earlier post, I hadn't set form1.button2 (the 'GO' button) as default which meant you had to either click it or use 'TAB' and then 'ENTER';  now as soon as you enter the ID, you can press 'ENTER' and off it goes.  Sorry about that.
In the attachment, I've also used a slightly different approach - what I call 'form cloning' (I'm sure there must be a more technical term - LOL!).  It appears as if you are working on the same form but in fact you are flipping between the two.  As I see it, there are a number of advantages:
1.  it's still standard MVD so there is little scripting (if any) to do.
2.  you can designate different buttons as 'default' on each screen which speeds the user up.
3.  you can set what fields are enabled/disabled using object properties (again, standard MVD) rather than switching them on and off by script.
Not saying any approach is right or wrong - just shows how flexible MVD can be.
Derek.

2,323

(5 replies, posted in Script)

Hello Clyde, EHWagner, Dmitry,
As you can see already from EH and Dmitry, there are a couple of ways of doing it.
I like to keep to 'standard' MVD as much as possible so I think I'd probably use a hidden tablegrid to retrieve the record details and then call a second form on which editing can be done.  It certainly keeps the script short!
Attached is an example and hopefully it gives you more ideas/options.
Derek.

2,324

(4 replies, posted in General)

Hello Adam,
As I said in my last post, you can just replace the .visible with .enabled in the relevant lines in the script and change the object properties on the form.  Anyway, it's in the attachment.
I was confused by form1.tgprod and form1.tablegrid1 - they both show product data so wasn't sure why you have both on the form.
If you're serious about using just one form, I'd strongly advise at least the following:
1.  setting your fields to mandatory, where possible. 
2.  conditionally hide the 'save' button unless either the 'own product' or the 'purchased product' checkbox is ticked.
I say this because it is far too easy just to accidently click 'save' and create empty records (or, once you've added an 'edit' button), to create duplicates of existing records as well.  Try clicking 'save' a few times and see what happens. 
Just my opinion, for what it's worth.
Derek.

2,325

(4 replies, posted in General)

Hello Adam,
I use showing/hiding groupbox/panel simply because you only need to issue one set of instructions that then includes all the objects contained within the groupbox or panel.  But the principle is exactly the same for individual edit fields etc etc.
Attached is your example working as I believe you want it to (and with the script changes commented - I'm sure Mathias thinks I never comment my code - LOL!!  Only joking). 
(If you want to use enable/disable rather than visible/invisible, simple change the script from .visible to .enabled and change the default settings on the object properties on Form1 from visible = false to enabled = false).
Derek.