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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a Form "Forget" Its Objects

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
US
I have a form which is pretty simple:
* 2 OptionGroups
* 2 Simple Grids
* 2 OLE Objects - 'oleFirstDate' & 'oleLastDate' Calendars
* 1 ComboBox
* 1 Command Group with 2 buttons

The OLE Calendars are Microsoft Date and Time Picker Control 6.0 (SP6).

With my OK.ClICK method I use the following code, so I assume that is where the error is occuring.
Code:
mcDay = PADL(ALLTRIM(STR(THISFORM.oleFirstDate.OBJECT.DAY,2)),2,"0")
mcMonth = PADL(ALLTRIM(STR(THISFORM.oleFirstDate.OBJECT.MONTH,2)),2,"0")
mcYear = STR(THISFORM.oleFirstDate.OBJECT.YEAR,4)
mcFirstDate = mcMonth + "/" + mcDay + "/" + mcYear
mdFirstDate = CTOD(mcFirstDate)

Most of the time these things all work together well.

But sometimes I get an error message indicating...
Unknown member OLEFIRSTDATE

Can the Form somehow "Forget" its objects?
How do I ensure that this type of error goes away?

As always, your advice and suggestions are most welcome.

Thanks,
JRB-Bldr
 
Did you have any problems with this:
Code:
WITH thisform.oleFirstDate.Object
     mdFirstDate = DATE(.Year, .Month, .Day)
ENDWITH

or even with this:
Code:
WITH thisform.oleFirstDate  && No OBJECT reference here
     mdFirstDate = DATE(.Year, .Month, .Day)
ENDWITH
I ask because I never worked with Calendar Control

Borislav Borissov
 
No, my error log (from the error handler portion of faq184-4492) indicates that this error message is being thrown up during the execution of the OK.Click method.

The ONLY place within that method code where that OLEFIRSTDATE is referenced is the code shown above.

Thanks,
JRB-Bldr
 
Boris - I have not tried it the way that you suggest.

I am currently following the method I found on the web for using that OLE object.

However, my problem is not the date conversion itself.
I assume (although I am not certain) from the error message
Unknown member OLEFIRSTDATE
that the problem is the Form's "knowing" about OLEFIRSTDATE.

And if the problem were with the OLE object's properties (DAY,MONTH,YEAR), then why would it work most times and not work some time?

I always initialize the both of the OLE Calendar Objects to a known good date ( DATE()-1 ) during the Form.Init method.

Thanks,
JRB-Bldr
 
FWIW, I don't think you need to build the date that way. Try looking at the Value property of the OLE Control.

Code:
mdFirstDate = TTOD(ThisForm.oleFirstDate.Object.Value)

Tamar
 
O, I see, What this gives you in error handler:
(I hope you use VFP8 or VFP9)
Code:
ASTACKINFO(laStack)
LIST MEMO LIKE laStack TO FILE lcError.TXT
MODIFY FILE lcError.TXT

Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top