Hi,

I'll give an overview of my program. I'm using MFC and an Access database. In my FormView class the user clicks the "Find Trade" button. This generates a "FindTrade" dialog box which has a list control populated with the contents of a database as well as an "Edit" button.

The user selects an item in the list control and then clicks the "Edit" button. This generates an "Edit Trade" dialog box with edit controls populated with the field contents of the record selected in the list control. Once the user edits any data in the edit controls the "EditTrade" button is clicked. This updates the record in the database just fine.

What I would like to is have a function in my CTransactionSet class called UpDateItem() that will update the list control in "FindTrade" dialog with the record that was edited. The problem I'm having is trying to figure out how to pass the address of the list control in my "Find Trade" dialog box to a function, UpdateItem() in my Recordset class.

I thought of passing it the address in the DoModal() for CEditTradeDialog. To be honest I'm not completely how to pass the address of the list control.



Below is the code for OnButtonEdit() from FindTrade dialog box
Code:
void CFindDialog::OnButtonEdit() 
{
     //AfxMessageBox("You clicked the Edit Button");

     CTransactionSet TmpSet;
     CListCtrl* pList;
     pList = &m_lcTradeList;
     TmpSet.Open();
     CEditTradeDialog TmpEdTrdDlg;

     int nTransID;

     this->nLcReturnValue = m_lcTradeList.GetNextItem(-1,LVNI_SELECTED);
     int nItemIndex = this->nLcReturnValue;

     if(this->nLcReturnValue == -1)
     {
          AfxMessageBox("You must select and entry");
     }
     else

     {

          CString y;
          y.Format("The unique ID is %d" ,nItemIndex);
          AfxMessageBox(y);

          
          
          
          
          nTransID = m_lcTradeList.GetItemData(this->nLcReturnValue);
          CString z;
          z.Format("The TransactionID is %d",nTransID);
          AfxMessageBox(z);


          CString sel;
          sel.Format("the TransactionID at %d is %d ", nItemIndex, nTransID);
          AfxMessageBox(sel);



          

     }


                //I thought of passing the address in the Domodal()
     TmpEdTrdDlg.DoModal(nTransID, pList);

     
}
This is the code for OnEditTrade() from the EditTrade dialog box


Code:
void CEditTradeDialog::OnEditTrade() 
{

     UpdateData(TRUE);

     CTransactionSet TmpTransSet;

     
     if(!TmpTransSet.IsOpen())
          TmpTransSet.Open();

     TmpTransSet.Edit();

     TmpTransSet.m_Buyer = m_strBuyer;
     TmpTransSet.m_Seller = m_strSeller;

     TmpTransSet.m_BuyerBrokerNumber = atoi(m_strBuyerBrokerNumber);
     TmpTransSet.m_BuyerBrokerCommission = atof(m_strBuyerBrokerComm);

     TmpTransSet.m_SellerBrokerNumber = atoi(m_strSellerBrokerNumber);
     TmpTransSet.m_SellerBrokerCommision = atof(m_strBuyerBrokerComm);



     TmpTransSet.m_TradeDate = m_strTradeDate;
     TmpTransSet.m_SettlementDate = m_strSettlementDate;
     TmpTransSet.m_MaturityDate = m_strMaturityDate;

     TmpTransSet.m_Amount = m_strAmount;
     TmpTransSet.m_Rate = atof(m_strRate);

     TmpTransSet.m_NumberOfDays = atoi(m_strNumberOfDays);


     TmpTransSet.m_CollateralDescription = m_strSecurityDescription;




     TmpTransSet.Update();

     

     this->ClearContents();

     //TmpTransSet.UpdateItem(this->mpList);

     CDialog::OnCancel();

     





     
}
Below is the code I've started for UpdateItem() from CTransactionSet

Code:
void CTransactionSet::UpdateItem(CListCtrl *pList, int Item)
{

     AfxMessageBox("In UpdateItem()");

     int nTrade = pList->GetItemData(Item);

     this->LocateTrade(nTrade);

     pList->SetItemText(Item,0,this->m_Buyer);
     pList->SetItemText(Item,1,this->m_Seller);

   





}