Thank you for you assistance. I have changed my code like you said (at least
I thought I did). I am still having the same problem. When the StartTime
code is befor the EndTime code, I get the "Object not in form" error.

Below is the code with changes. This time I included the entire function.

Thank you again,

Todd

static void ServicePeriodFormOpen(FormPtr)
{
 MemHandle currentRecordH;
 ServDBRecord *currentRecordP;
 FormPtr frmP;
 static Char datelbl[20];
 Char *startTime;
 Char *endTime;
 static Char *startlbl;
 static Char *endlbl;

 FieldType *datefldP;

 frmP = FrmGetActiveForm();

 // Get ServicePeriod record
 currentRecordH = DmQueryRecord(gServDB, gCurrentIndex);
 currentRecordP = MemHandleLock(currentRecordH);

 // Save current record in global for later reference
 gCurrentRecord = *currentRecordP;

 // Move date to screen
 DateToDOWDMFormat(gCurrentRecord.start.month,
gCurrentRecord.start.day,gCurrentRecord.start.year,
      sysPrefs.longDateFormat,datelbl);
 datefldP = (FieldType *)FrmGetObjectPtr(frmP,FrmGetObjectIndex(frmP,
ServicePeriodDateField));
 FldSetTextPtr(datefldP, datelbl);

 // Move start time to screen
 startTime = MemPtrNew(timeStringLength);
 (const Char*)startTime =
CtlGetLabel(GetObjectPtr(ServicePeriodStartSelTrigger));
 TimeToAscii(gCurrentRecord.start.hour,
gCurrentRecord.start.minute,sysPrefs.timeFormat, startTime);
 startlbl = MemPtrNew(StrLen(startTime)+1);
 StrCopy(startlbl, startTime);
 CtlSetLabel(GetObjectPtr(ServicePeriodStartSelTrigger),startlbl);

 // Move end time to screen
 // If new record with no end time, use default label label; else end time
 if (gCurrentRecord.end.hour != noTime)
 {
  endTime = MemPtrNew(timeStringLength);
  (const Char*)endTime=
CtlGetLabel(GetObjectPtr(ServicePeriodEndSelTrigger));
  TimeToAscii(gCurrentRecord.end.hour,
gCurrentRecord.end.minute,sysPrefs.timeFormat, endTime);
  endlbl = MemPtrNew(StrLen(endTime)+1);
  StrCopy(endlbl, endTime);
  CtlSetLabel(GetObjectPtr(ServicePeriodEndSelTrigger),endlbl);
 }




 MemHandleUnlock(currentRecordH);
 gNewRecord = false;

}

"David Fedor" <[EMAIL PROTECTED]> wrote in message
news:72545@palm-dev-forum...

> I'm pretty sure the problem is that you're calling TimeToAscii, putting
the
> results into endTime, but not making sure that endTime is a big enough
> buffer to fit the time value... it is only as big as whatever was in the
> trigger before.
>
> Do a MemPtrNew to allocate a buffer of at least "timeStringLength" bytes,
> then call TimeToAscii, then call CtlSetLabel.  More efficient and correct
> too, how about that? :-)  (Don't forget to free the memory that you
> allocate, though...)
>
> -David Fedor
> Palm, Inc.
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to