>Tis can't be done. A dataenvironment can only be contained in a form. If oyu want to create a custom one, add it to the form.
Sorry Erik, you're only half right. < G > I use custom dataenvironment classes all the time. However, I've never tried to add cursors at runtime via addobject. I define the DE class in code, for example:
define class denBenMatrix as DataEnvironment
Name = "denBenMatrix"
add object "alsBenDs" as "Cursor"
alsBenDs.Alias = "alsBenDs"
alsBenDs.BufferModeOverride = 3
alsBenDs.CursorSource = "BenDs_For_Rec_Type"
alsBenDs.Database = fullpath(dbc())
alsBenDs.NoDataOnLoad = .T.
add object "alsBenMx" as "Cursor"
alsBenMx.Alias = "alsBenMx"
alsBenMx.BufferModeOverride = 5
alsBenMx.CursorSource = "BenMx_With_Tos_Descr_For_Mtx_Id_By_Tos_Descr"
alsBenMx.Database = fullpath(dbc())
alsBenMx.NoDataOnLoad = .T.
enddefine
HTH,
Bill Armbrecht
VFP MCP