onCalendar function

Can anyone please suggest a reason for and a solution to my programming errors for date entry using the onCalendar function? I have very little experience with Java.
My form has a date field that is popuated by a databasae data provider, dateentered. There is also a button next to the date field that I want to use to bring up the onCalendar pop-up function. It should load the date from the dataprovider to use as a pre-selected date value and allow the user to change it using the pop-up. I can get the pop-up to show up but the pre-selected value is not set, and when I change the date in the pop-up it does not update the dataprovider field.

the button performs this method onAction:

globals.gDate=dateentered;
globals.getCalendarDate()
dateentered = globals.gDate

the globals.getCalendarDate() method does this:

// Function will display a date in a Calendar prompt and return the date
gdate=application.showCalendar();
return(globals.gDate);

Hey there,
This is how I was able to call the Calendar Picker and set a dataprovider to what I selected:

//declare a variable ‘datepicked’ first
var datepicked = application.showCalendar();
//then, set the dataprovider ‘datefield’ equal to your variable
if (datepicked != null) //checks to make sure ‘datepicked’ has something in it
{
forms.calendarPicker.datefield = datepicked;
}

This works really well. The last if statement is needed in case the user hits the Cancel. Without out it, a null value would be returned to my data provider.

For the other part of your question, setting the calendar picker to a date in your data provider, I haven’t tried. Hopefully, this will at least help.

Thanks for your help. Yes that does work! Now if I could only set the date before onCalendar is called. The date is set to the system date the first time it is called, but reverts to the last selected value on subsequent calls.
Does anyone know how this can be set before the onCalendar code is run?

Are you aware of the field_type CALENDAR?(=field with button showing calendar) it seems you try to build something which is already there ;-)

It’s funny, that’s how I first came up with the method. When I first started working with Servoy, I didn’t realize there was a Calendar setting for the field property!

But, now that I do have a method, I can do just about anything with it. Assign it to my own “calendar” graphic. Trigger it onFocus, or just about anything. Whether used as a property or in a method, it’s a way cool feature. Thanks!

Are you aware of the field_type CALENDAR?(=field with button showing calendar)

No I was not. Thanks!