Fred
Mon Dec 06 00:10:57 CST 2004
Posting sample forms is a bit difficult.
All you really need is to have a form property as the ControlSource, and in
the DTPicker.Change, you'd handle the updating the property and or your
table's value. You'd need code elsewhere that would handle moving the data
from the table field to the form property, keeping it within limits you've
set on the DTPicker and also handling NULL or EMPTY() date values. The
DTPicker can only have real date values that are between the MinDate and the
MaxDate of the DTPicker, so you'd have to insure that the form property
never falls outside those limits (or else you'll see an error). When you
update the property on the form, you'd also need to refresh the control.
Say your form property is named "DTPickerValue" and you have a table named
DLIST with a date field named "d1":
DTPicker.ControlSource = "thisform.DtPickerValue" && leave the quotes
off if entering in the property sheet
DTPicker.Refresh:
LOCAL cCS
cCS = this.ControlSource
&cCS = IIF(EMPTY(dlist.d1) OR ISNULL(dlist.d1) OR NOT
BETWEEN(dlist.d1,this.MinDate,this.MaxDate),TTOD(this.MinDate),dlist.d1)
DTPicker.Change:
LOCAL cCS
cCS = this.ControlSource
&cCS = TTOD(this.Object.Value)
REPLACE d1 WITH &cCS IN dlist
Just be sure the intial value of your property fits the MinDate/MaxDate
range or the property will become unbound from the control.
--
Fred
Microsoft Visual FoxPro MVP
"Hutch Elassaad" <helassaad@comcast.net> wrote in message
news:j5WdnZlhzfYc2i7cRVn-rw@comcast.com...
> Fred,
>
> I didn't quite understand Anders example. Although he had tried helping
> me
> on several occassions before. (My hat goes off to him for supporting this
> NG)
> Can you please do me a favor and
> send me an example. Nothing really major. Just a table that has a date
> in
> it and a form with the default buttonset (default text navigation buttons
> at
> the bottom of the form) and show me how when I add or edit a record I can
> use the datetime picker on the form with the binging that you mentioned.
> I
> may be thinking too much into it.
>
> thank you
>
> Hutch
>
>
> --
>
>
> ---------------------------------------------------------------------
> "Are you still wasting your time with spam?...
> There is a solution!"
>
> Protected by GIANT Company's Spam Inspector
> The most powerful anti-spam software available.
>
http://mail.spaminspector.com
>
>
> "Fred Taylor" <ftaylor@mvps.org!REMOVE> wrote in message
> news:uIhUFuk2EHA.1192@tk2msftngp13.phx.gbl...
>> Anders covered the topic pretty well. Binding is merely associating the
>> ControlSuurce of the control with a field in a table/cursor/view or a
>> variable/property. In most cases, you would use a field, but since dates
> in
>> SQL have this difference from VFP of not allowing an EMPTY date, you need
> to
>> associate the ControlSource with a form property (a variable would go out
> of
>> scope unless you used a PUBLIC variable, which is not something you
>> should
>> do). The problem then exists that you have to manually shuttle the value
> of
>> the property back and forth to the table, as Anders has shown.
>>
>> --
>> Fred
>> Microsoft Visual FoxPro MVP
>>
>>
>> "Hutch Elassaad" <helassaad@comcast.net> wrote in message
>> news:36ydnd1LI4aHcCzcRVn-rQ@comcast.com...
>> > Fred,
>> >
>> > What did you mean by binding to a form property. I never used binding
> and
>> > may be it is the right time to start understanding it and using it.
>> > The help file didn't explain much to me, but I am getting the "What's
> new
>> > in
>> > visual foxpro 8".
>> >
>> > thanks
>> >
>> > Hutch
>> >
>> > --
>> >
>> >
>> > ---------------------------------------------------------------------
>> > "Are you still wasting your time with spam?...
>> > There is a solution!"
>> >
>> > Protected by GIANT Company's Spam Inspector
>> > The most powerful anti-spam software available.
>> >
http://mail.spaminspector.com
>> >
>> >
>> > "Fred Taylor" <ftaylor@mvps.org!REMOVE> wrote in message
>> > news:uXgIMNP2EHA.204@TK2MSFTNGP10.phx.gbl...
>> >> Be aware that you can't use an EMPTY() or NULL date field value
>> >> because
> I
>> >> don't think those are valid values for that control.
>> >>
>> >> You might need to bind to a form property that you change according to
>> >> the
>> >> field value. Substitute today's date or some other constant date when
>> >> the
>> >> date field is NULL or EMPTY(), or less than the MinDate property.
>> >>
>> >> Also be sure to set the MinDate and MaxDate properties. You can use
> Jan
>> > 1,
>> >> 1601 (1/1/1601) for the MinDate, and December 31, 9999 (12/31/9999)
>> >> for
>> > the
>> >> MaxDate.
>> >>
>> >> --
>> >> Fred
>> >> Microsoft Visual FoxPro MVP
>> >>
>> >>
>> >> "Hutch Elassaad" <helassaad@comcast.net> wrote in message
>> >> news:Zf2dnY3mrrqZSTLcRVn-qg@comcast.com...
>> >> > Fred, I am going with a vanilla code here. I have a form where I
> drop
>> > the
>> >> > datetime picker and the control soucrce points to a field in the
> table
>> >> > defined as type datetime. When I edit the record and try to change
> the
>> >> > time, it doesn't work. It reverts back to whatever was saved
>> >> > before.
>> >> > Also
>> >> > if there was an invalid date in the field in the table, I get some
> sort
>> > of
>> >> > an error. I allowed for null values for that field in the table.
>> >> >
>> >> > --
>> >> >
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > "Are you still wasting your time with spam?...
>> >> > There is a solution!"
>> >> >
>> >> > Protected by GIANT Company's Spam Inspector
>> >> > The most powerful anti-spam software available.
>> >> >
http://mail.spaminspector.com
>> >> >
>> >> >
>> >> > "Fred Taylor" <ftaylor@mvps.org!REMOVE> wrote in message
>> >> > news:uUbMdqN2EHA.3468@TK2MSFTNGP14.phx.gbl...
>> >> >> What problem are you having? You might just need to add the key
>> > phrase
>> >> >> "object" to your references to get at some of the properties:
>> >> >>
>> >> >> thisform.oDTPicker.Object.Value
>> >> >>
>> >> >> --
>> >> >> Fred
>> >> >> Microsoft Visual FoxPro MVP
>> >> >>
>> >> >>
>> >> >> "Hutch Elassaad" <helassaad@comcast.net> wrote in message
>> >> >> news:bpadnebPme4JIjLcRVn-vg@comcast.com...
>> >> >> > Anyone knows of a replacement of the Datetime Picker?
>> >> >> > I've had nothing but bad luck in trying to make it work. I
> remember
>> >> > many
>> >> >> > of
>> >> >> > the conversations that dealt with this before, but I can't get it
> to
>> >> > work
>> >> >> > right. Does anyone have any clear instructions? or a replacement
>> >> >> > object
>> >> >> > to
>> >> >> > use?
>> >> >> >
>> >> >> > Thank you,
>> >> >> >
>> >> >> > Hutch
>> >> >> >
>> >> >> > --
>> >> >> >
>> >> >> >
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> > "Are you still wasting your time with spam?...
>> >> >> > There is a solution!"
>> >> >> >
>> >> >> > Protected by GIANT Company's Spam Inspector
>> >> >> > The most powerful anti-spam software available.
>> >> >> >
http://mail.spaminspector.com
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>