Topic: Date Picker - set date

Hi

I am trying to find my way with visual database.. got most things working but need to make it easier to use

I have a form with to options for date using the date picker

Box one, is set to todays date (test date)
Box two is to be set 365 days later (ie next test due)

How can I do this? Think it is in sql, but not sure

If sql, can you give an example
If sql where do I put the sql, and how to apply it

Thank you

Re: Date Picker - set date

Hi TCSplinters,
There are a couple of ways to do this but for me, the easiest is to use a calculated field.
Please see attached and let me know if anything's not clear.
Regards,
Derek

Post's attachments

Attachment icon tcsplinter dates.zip 337.08 kb, 336 downloads since 2018-03-20 

Re: Date Picker - set date

tcsplinters,
Just saw that Derek already responded. Sorry. Here is another option. I included a "Plus 365 Days" and a "Plus 12 Months" on the form. They both result in the same answer except on February 28 of a leap year. The 12 months option is accurate in that case, but only by one day.

Post's attachments

Attachment icon Dates_tcsplinters.zip 579.63 kb, 342 downloads since 2018-03-20 

Re: Date Picker - set date

Thank you both for the assistance. 

Does MVD have the ability to have a radio button, (ie options that allow only one to be selected).  Can only see checkboxes, and they allow multiple selections

Have the sual problem of 'creeping' elegance... want to keep improving

So idea being
Radio buttons to select 3month / 6 month or 12 month, with calendar updating.

thank you

Re: Date Picker - set date

Hi ehwagner

Tried your scripted version.. but cant get the change date version to work

Not sure what I am missing!

procedure frmResults_OnShow (Sender: TObject; Action: string);
begin
    frmResults.dtNextDue.DateTime:= frmResults.dtTestDate.DateTime + 365;
end;

procedure frmResults_dtTestDate_OnChange (Sender: TObject);
begin
    frmResults.dtNextDue.DateTime := frmResults.dtTestDate.DateTime + 365;
end;

begin

end.

Thank you

6 (edited by derek 2018-03-21 09:56:45)

Re: Date Picker - set date

Hi,
MVD doesn't have radio buttons as 'standard' but you could use checkboxes (or pictures of radio buttons).  But you'd then have to write a couple of lines of script to make sure that they are mutually exclusive (not that that's a problem but I try to use standard MVD where possible).
The other option is to pick your time interval from a combobox and use it in the calculated field calculation (please see attached).
Let me know if anything's not clear.
Derek.

Post's attachments

Attachment icon tcsplinter dates.zip 338.39 kb, 368 downloads since 2018-03-21 

Re: Date Picker - set date

Hello TCSPLINTERS, Hi EHW,
I wonder if you haven't created any 'events' that link an 'object' to procedures in your script (sorry for the terminology!).

1.  When you use scripting, you will see an 'events tab' for each object (a form, a button, a grid, a field, a label etc etc)
2.  In this example, if you want to create an 'on show' event for Form1, you need to click (3 times) on the specific event
3.  This will automatically created a 'Form1_OnShow' entry against that event and link you to the scripting screen.
In other words, you can't just go into the script and write some code without making sure that the link is in place, otherwise it will never run.
So, in your example, you'll need to create events for frmResults_OnShow and frmResults_dtTestDate_OnChange.
Please have a look at the attached screenshot which might make things clearer.
Hope that helps,
Derek.

Post's attachments

Attachment icon tcssplinters.jpg 148.66 kb, 188 downloads since 2018-03-21 

Re: Date Picker - set date

Hi

Thanks Derek, yes I missed the on change event.  Thank you for your clear instruction.  All fixed.  Will look at using standard features to make a selectable option for the dates.

Thanks for all the help
tc