Hello all,

I have a program that displays a list of medications for the user to pick
from. The list is dynamically created from a database. The problem I am
having is with selecting a medication to delete. Whenever I select a
medication then tap "Delete" I get an error about reading from low memory.

Code is as follows:
//code from event loop:

                case DeleteEditDeleteButton:
                    listP = GetObjectPtr(DeleteEditListList);
                    selection = LstGetSelection (listP);
                    selectionText = LstGetSelectionText (listP, selection);
                    index = GetRecordNumberOfDrug(selectionText); //routine
to find the record number of drug for the next function call.
                    DmRemoveRecord (gDataBase, index);
                    LstEraseList (listP);
                    SetUpDrugList (DeleteEditListList);
                    LstDrawList (listP);
                    handled = true;
                break;


Also, since I can't get the above to work yet. I was wondering if any one
could comment on my function to return the record number of the database
record choosen from my list. Does it look like it will work?

static UInt16 GetRecordNumberOfDrug(Char* name)
{
    UInt16 theCategory = dmAllCategories;
    UInt16 totalItems = DmNumRecordsInCategory (gDataBase, theCategory);
    UInt16 i;
    UInt16 recordNum = 0;
    MemHandle recordHdl;
    PackedDrugs *packedDrug;
    Drugs drug;
    Boolean foundIt;
    
    for (i = 0; i < totalItems; i++, recordNum++)
    {
        recordHdl = DmQueryNextInCategory (gDataBase, &recordNum,
theCategory);
        packedDrug = MemHandleLock (recordHdl);
        UnpackDrug (&drug, packedDrug);
        foundIt = StrCompare (name, drug.name);
        MemHandleUnlock (recordHdl);
        if (foundIt)
        {
            break;
        }
        
    }
    
    return recordNum;
}

Any help/input is greatly appreciated.

Thanks,

Andy



-- 
Andy Black
[EMAIL PROTECTED]
Unix is user friendly. It is just picky about who its friends are.



-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to