Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time Field Formatting

Status
Not open for further replies.

michlm

Programmer
Sep 3, 2000
44
0
0
US
I have two input text boxes so that a user can enter a start date/time and an end date/time. Neither text box has a control source since I'm using it to capture info for my filter. How do I format the text box for date/time so my user can see they need to enter it in a date/time format? Is this even possible? I've checked the format property and input mask property and don't see any date/time information. I know that for a date you can put {} in the value field - is there anything for date/time or do I have to make the date a date field and the time a character field and then try to put them together to convert them to date/time data type? Any insight would help. Thanks.

Michelle
 
Michelle-

This is not a specific answer as I'm not good at visualizing
others concepts. No go on an input mask so I looked for other alternatives. Have pondered this and will offer up a link that you might wish to study. Uses the ActiveX Calendar Control that ships with VFP as a "hook" to a tables date field.

Example is written for 5.0 (one I skipped, loaded and never used, always a couple behind) I use 7.0. I created the form from the example and the concept is neat. Probably old stuff to you.

MSDN Q158248 Title "HOWTO: Use the Calendar Control to Enter and Display Dates"

Got an application pending that will need a similar interface so today was a good day to look it up.

Hope it helps,

Jack
Rainy again in Georgia
 
Michelle,
Put ={ / / : :} in for the intial Value.

This forces the field type to be DateTime.

Rick
 
HI
Rick is right in his suggestion. That will intialise field type.

1. In the init event of the form..add the code
PUBLIC dtStart, dtEnd
STORE DATETIMT() TO dtStart, dtEnd

2. Set the textboxes ControlSource as m.dtStart and m.dtEnd respectively. The advantage is that the starttime and endtime are initialised to current date and time.. which will be a guide to the users.. instead of showing simply //::
This will help user to avoid wrong date input.

3. You can also validate.. just before writing the data.. that m.dtStart < m.dtEnd.. and setting the focus back to the end text box, in case of error. Remember the user can go back to start or end fields by clicking in a wrong order.. and so valid event cannot catch the error effectively or helpfully.

Hope this help you :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top