Semi-automatic Date Picker on every Date field - in 3 steps

WaldoWaldo Member Posts: 3,412
edited 2012-04-27 in NAV Tips & Tricks
I know I know .. Probably all of you already implemented it, but for those who didn't … here's how :)

Probably everybody knows the functionality when putting a question mark ('?') into a text field, that the standard text functionality pops up?

Well, I've got an easy-to-create variant of this for dates.

What do you have to do?

1. Download the Date Time Picker from Mibuso: http://www.mibuso.com/dlinfo.asp?FileID=563 (thanks Woody)
2. Import it in your database (obviously you don't need the sample form)
3. Add this code to codeunit 1 in trigger "MakeDateText" (create a local variable of the type "form" for your Date Picker":
IF DateText IN ['?',' '] THEN BEGIN
  lfrmDatePicker.SetCurrDate(TODAY);
  lfrmDatePicker.LOOKUPMODE(TRUE);
  IF lfrmDatePicker.RUNMODAL = ACTION::LookupOK THEN BEGIN
    DateText := FORMAT(lfrmDatePicker.GetCurrDate);
  END;
END;

It might be that you have to restart your client.

Now just put a ' ' or a '?' into a date field and there is your date picker.

Enjoy!

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Excellent tip! It's almost an MVT (Most Valuable Trick) ;-)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    In the past I remember using the Monthly Calendar (7609) form for this.

    It is a brilliant matrixform to pick dates and available in almost every navision database.

    Just add an OK button on it and return the selected date when pushed.
  • WaldoWaldo Member Posts: 3,412
    Indeed, but do you know which granule is needed for this form?

    Anyway, for the OK button: this will give you the selected date:

    "Period Start" + DATE2DWY(CurrForm.Matrix.MatrixRec."Period Start",1) - 1

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • ara3nara3n Member Posts: 9,255
    The granules are

    3,360 Sales & Receivables - Calendars
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • tompynationtompynation Member Posts: 398
    How do you guys do this with the Monthly Calendar control?

    I added this in the MakeDateText trigger of CodeUnit 1.
    lfrmDatePicker is now a variable of Form "Monthy Calendar".

    IF DateText IN THEN BEGIN
    // lfrmDatePicker.SetCurrDate(TODAY);
    lfrmDatePicker.LOOKUPMODE(TRUE);
    IF lfrmDatePicker.RUNMODAL = ACTION::LookupOK THEN BEGIN

    END;
    END;

    How do you add the return value to the OK button?
    The pushaction of my button is LookupOK

    But where do you add the line: "Period Start" + DATE2DWY(CurrForm.Matrix.MatrixRec."Period Start",1) - 1
    Is this the RunCommand?

    Cause i cannot get it to work the return the selected date
  • tompynationtompynation Member Posts: 398
    allright, got it working
  • lgplgp Member Posts: 77
    Hi - I am trying out the Date Picker in NAV2009R2. After selecting a date with the Date Picker, if I go directly to the next date field and type '?', I get an error: "The form has been run. Use the function CLEAR(Form)". Has this been reported, and is there a fix? Thanks...
    Leanne G. Paul
    Business Applications/IT Advisor, Competitive Edge Services
  • ara3nara3n Member Posts: 9,255
    you need to add the following line.

    clear(lfrmDatePicker.) ; //new line.
    lfrmDatePicker.SetCurrDate(TODAY);
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • lgplgp Member Posts: 77
    Thanks!
    Leanne G. Paul
    Business Applications/IT Advisor, Competitive Edge Services
Sign In or Register to comment.