Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child recordset. How to use?

Status
Not open for further replies.

Jaco

Programmer
Aug 29, 2000
57
PL
I have a datagrid sourced to a child recordset in the dataenvironment. How do I refer to data and add a new record to this child recordset? The child looks like an extra field in the parent recordset but I cant work out how to add a new record and fill it from code

Regards, Jaco
 
How to add a new record to a child record in the DataEnvironment with data from 3 unbound text entry boxes. I type entries in these boxes and click on the AddnewChild button. No refreshing is needed.
Assumes ChildRecords is a child command of a parent table and appears as a field (ChildRecords) in the parent list. DatagridC is connected to ChildRecords.
Sub AddNewChild_Click()
Dim rsChild As Variant
Set rsChild = DataEnvironment1.rsParentRecords.Fields("ChildRecords").Value
DataGridC.AllowAddNew = True
DataGridC.SetFocus
rsChild.AddNew 'shows new record row
rsChild.Fields("ChildFirstName") = ChildFirstName.Text 'or rsChild.Fields(0)=
rsChild.Fields("ChildSecondName") = ChildSecondName.Caption ' ''or rsChild.Fields(1)=
rsChild.Fields("ChildAge") = ChildAge.Text
DataGrid9.AllowAddNew = False
ChildFirstName.text= ""
ChildSecondName.Text = ""
ChildAge.Text = ""
Set rsChild=Nothing
End Sub

Any data in child records can be read or written to by using rsChild.Fields(N) and you can use all the usual rsChild.MoveNext or EOF etc. but you dont see the drop down lists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top