Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 653
  • Last Modified:

diarydate calendar in vfp retrun data to form

Hi: Writing a purchase order system I need to set a required date.  I use the diary date to call up a calendar. The problem is that there does not appear to be a way to get the date selected from the calendar back to the form, without calling the diary date again.
I have this on the click function of a button next to the text box to which I wish to post the date:
ACTIVATE WINDOW calendar
due = _DIARYDATE
THISFORM.Text3.Value = due
Which gives the date currently selected in the calendar ( set at the init stage of the form thus:
_diarydate =  IIF(CDOW(DATE()+1)="Saturday",DATE()+3,DATE()+1))
But if I want to choose a different date, say I choose 31/12/2015 in the calendar, how do I get this new date visible back on the form, without having to click the button again?
Sorry if a dumb question......
0
ClaytonGlass
Asked:
ClaytonGlass
  • 4
  • 2
1 Solution
 
Olaf DoschkeSoftware DeveloperCommented:
The calendar window updates _diarydate, so you could bind to that variable, but there is no way to get a notification/event, when a variable value changes.

You better use a calendar control (OCX), eg mscal or datepicker.

Bye, Olaf.
0
 
ClaytonGlassAuthor Commented:
Olaf - if you say so , it must be true.
Thanks!
0
 
pcelbaCommented:
Never say "No way" in FoxPro...  :-)

You may try following code:
RELEASE goForm
PUBLIC goForm
goForm = CREATEOBJECT('Form')

goForm.AddObject('lblDate', 'Label')
WITH goForm.lblDate
  .Top = 20
  .Left = 50
  .Height = 20
  .Width = 150
  .FontSize = 16
  .Visible = .T.
ENDWITH

goForm.AddObject('timGetDiaryDate', 'MyDiaryTimer')

goForm.Visible = .T.
ACTIVATE WINDOW Calendar

DEFINE CLASS MyDiaryTimer AS Timer
Interval = 300
Enabled = .T.

PROCEDURE Timer
  THISFORM.lblDate.Caption = DTOC(_DIARYDATE)
ENDPROC

ENDDEFINE

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Olaf DoschkeSoftware DeveloperCommented:
Well, yes. A timer can be used in many cases, but then there is more to the calendar window less good. It has a note section, which stores notes to each date in a foxuser.dbf. That's per user. Fine, but often you want to not have any foxuser.dbf

Then to mimic a calendar control you'd show the calendar window at a click and wait for the window to be hidden to confirm the choice, or to close automatically, once date is selected or the preselected date is confirmed by clicking or double clicking it. So there are several exit scenarios, some involve a change of _diarydate, some of WVISIBLE('calendar') but what about just clicking on the preselected date? Neither _diarydate nor WVISIBLE() change.

It's much easier and straight forward to use a calendar control and even if you want to avoid OCX for the installation/distribution hurdle there are native solutions from craig boyd using a grid. See http://doughennig.com/papers/..%5CPub%5C200605dhen.pdf and of course http://www.sweetpotatosoftware.com/spsblog/permalink,guid,878c1b11-1770-405c-92ea-cdbe2c838dfa.aspx

Bye, Olaf.
0
 
Olaf DoschkeSoftware DeveloperCommented:
0
 
ClaytonGlassAuthor Commented:
Thanks to Olaf and pcelba for their expertise as usual!
I have  'doug hennig' date picker and dropped it on the form.
What I don't know how to do is make the data selected populate the field in the table; how do I make the connection between the calendar and the field?
Thanks!
0
 
Olaf DoschkeSoftware DeveloperCommented:
It has a controlsource property you use like normal.

Using the Date and DateTime picker classes is even easier. Drop a CalDatePicker or
CalDateTimePicker object onto a form and set ControlSource to the desired value, such as a Date or
DateTime field

Bye, Olaf.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now