Click to See Complete Forum and Search --> : Mu;tiple Recordset/ODBC/Access question


August 25th, 1999, 06:50 PM
I have a basic "add-change-delete" CRecordView based application which uses ODBC and Access.
Everything works great, and I am using a single CRecordSet. I would like to have simultaneous access to another CRecordset.
For simplicity (my actual case is more complicated), lets say my record view has 6 fields: Name, Address, City, State, Zip and Age. The Age is in its own recordset. For every name/address that I scroll through in the database, I would like the age of the person also displayed for each record.
I created a CDatabase object.
I then constructed a recordset, passing a CDatabase pointer to the CRecordset constructor.


// MyDoc.h
CMyPrimarySet* m_pSet;
CDatabase m_database;
//...




CMyDocument::OnNewDocument
{
if (!CDocument::OnNewDocument())
return FALSE;
if(m_pSet == NULL) {
m_pSet = new CMyPrimarySet(&m_database);
CString strConnect = m_pSet->GetDefaultConnect();
m_database.Open(NULL, FALSE, FALSE, strConnect, FALSE);
}
return TRUE;
}




I have this in my view's OnInitialUpdate:


CMyView::OnInitialUpdate()
{
//...
m_pSet = GetDocument()->m_editClearingLabelsSet;
//...
AgeRecordSet m_pAgeset(&pDoc->m_database);

}




Ok, I think I have the multiple recordsets set up correctly. Now, I am totally confused about the proper way to sequence through my records and have the age displayed along with each record.
I have tried several different ways, all to no avail.

Any clues?
Thanks in advance.

PeterK
August 26th, 1999, 02:27 PM
Do you have a field in one table that is the same in the other?

For example, you could store a customer ID in each table, or some type of AgeID in the customer table. You could use the ID we locate the proper record.