Hello all,

I am having some problems adding a new record to the database of my program.
In my program I put up a dialog box containing text fields and want to get
the data from those fields and put them into the database. When I click the
OK button to process the code to add the record, no record gets added. There
are still only the 2 records that I started out with in the database. I am
probable missing something simple here but it is driving me nuts. Any help
is greatly appreciated.

Here's some of the code:

//Add the drug to the database and pack it away. This function is called
from the the event handler(called when user taps the OK button) of the
dialog box that I put up.

static void AddDrugToDB()
{
    Drugs drug; //structure that I have defined to contain the data
    ControlPtr controlP;
    MemHandle recordHdl;
    UInt16 index = 0;
    
    recordHdl = DmNewRecord (gDataBase, &index, 1);
    if (!recordHdl)
        {
            ErrNonFatalDisplay ("Unable to add drug to the database. You
device may be full.");
        }
        else
        {
            //get data from form. GetLockedPtr returns text(Char*) of field
            drug.name = GetLockedPtr (AdddrugNameField);
            drug.mg = GetLockedPtr (AdddrugMgField);
            drug.ml = GetLockedPtr (AdddrugMlField);
            controlP = GetObjectPtr (AdddrugMcgKgMinPushButton);
            drug.mcgkgmin = CtlGetValue (controlP);
            
            //write data to new record. PackDrug resizes recordHdl as needed
then writes everything to the database.
            PackDrug (&drug, recordHdl);
            DmReleaseRecord(gDataBase, index, true);
        }
}

-- 
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