Solved

diarydate calendar in vfp retrun data to form

Posted on 2014-10-23
7
398 Views
Last Modified: 2014-10-24
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
Comment
Question by:ClaytonGlass
  • 4
  • 2
7 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 40399621
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
 

Author Closing Comment

by:ClaytonGlass
ID: 40399738
Olaf - if you say so , it must be true.
Thanks!
0
 
LVL 41

Expert Comment

by:pcelba
ID: 40400208
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40400355
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
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40400365
0
 

Author Comment

by:ClaytonGlass
ID: 40401946
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
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40402690
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now